Q: Can a method declare multiple return values? Or is there some way to return more than one return value?
Ans: Sort of.A method can return only one return value. But.. if you wanna return, say return three int values, then the declared return type can be an int array. Stuff those ints into an array, and pass it on back.
But you can’t return, let say an int and String for the same method.
Q: Does a method have to return the exact type it declared?
Ans: A method can return anything that can be implicitly promoted to that type. So, you can pass a byte where an int is expected. The caller wont care, because the byte just fits fine into the int the caller will use for assigning the result. But you must use an explicit cast when the desired type is smaller than what you are trying to return.
Q: Do I have to do something with the return value of a method? Can I just ignore it?
Ans: Java doesn’t require you to acknowledge a return value.You might want to call a method with a non-void return type,even though you don’t have care about return value. In this case you are calling the method for the work it has done inside the method, rather than what the method gives returns. In java you don’t have to assign or use the return value,but having said that if you really want to, you can assign a return value to that type of variable.