answersLogoWhite

0


Best Answer

A method in java can declare only one return value and type at a time. For ex: a single method cannot have a code that returns a string in some cases and an integer in other cases. Java compiler does not let you do that. You can only have one return type for every method in java.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

A Java method can only return one value, but this may be an object specially designed for containing multiple values (such as an array or collection).

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many values can a method return in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How many bits does a Java char contain?

16 bits. Java char values (and Java String values) use Unicode.


What is static void Main?

The String array args refers to the arguments that the program may require before starting. In many cases you may want the program to take some values as input for processing. this string array is for that purpose.


Where are a few of the places that one can learn more about Boolean values in Java?

There are a a few different websites that offer lessons on Boolean values in Java. The most reliable website is called HomeAndLearn because of its many different lessons.


How many method used to collect values in a form in php?

POST, GET & REQUEST will get the values from a form.


What is need for function overloading in Java?

To overload a method in java, you only needs to write a method with the same name of other in your class but with diferente kind or number of parameters. For example: class MyClass{ void printNumber(int x){ System.out.println(x); } void printNumber(int x, int y){ System.out.println(x+y); } } the type of the value that your method return could change if you want.


What's a JAVA program for Euler's totient function?

Implement this method: public static int totient(int n) { int count = 0; for(int i = 1; i < n; i++) if(gcd(n,i) == 1) count++; return count; } You can implement your own gcd(int a, int b) method, or find one of the many online.


Difference between method and constructor in java?

A constructor is technically a type of method, but it is a very special type. Whereas other methods can be used to do just about anything, the only purpose of a constructor method is to create an instance of the class that contains it, often with parameters passed to it through another part of the program. This instance is called an "object" and is a central part of not only Java, but other object-oriented languages as well. A constructor method always has the same name as its containing class, and does not have a return type. Think of it this way: a class in Java is like a generic blueprint for a house. Your instance variables are like different attributes of the house - how many bathrooms will your house have, what colour will it be? Once you decide on the exact specifications for your house, you can give those parameters to the construction company, which will actually create that house. That's what a constructor method does - takes input parameters (or, lacking them, sets defaults) and creates an object.


What are the advantages of using a Java Hashmap?

One of the advantages to using a Java Hashmap is that it allows one to use null values in it. Another advantage is its speed by splitting data into many 'buckets' and reducing the length of search times.


How many values you can return by call by value and call by reference at a time?

A function can only return one value, but it can modify its parameters if their type is 'in out' or 'out'.


What do the following functions return count and countif?

Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.Both return a total amount of values in cells. COUNT counts how many cells contain numbers. COUNTIF is used to count things that meet certain conditions.


Control statements in java?

A programming language uses control statements to cause the flow of execution to advance and branch based on changes to the state of a program. control statements are mainly three types in java. they are selection, iteration, and jump.


How many values at the most can be returned to the calling function through a single return statement?

It depends on the language. Python, for instance, can return any number of values. However, it's best to keep the number of return values as low as possible for the sake of simplicity and readability. Most languages only allow one return value at most, but languages that allow you to create new types (classes or structures) also allow you to return multiple values through objects of those types. That is, an object is just one value, but it may have one or more member objects or values embedded within. Failing that, if the language provides a "tuple" type then you can use that. If the return values are of the same type then you can also return multiple values via an array, or a pointer to an array, or a list, or any other sequence container provided by the language.