Recall & Review
beginner
What is a return value in Java?
A return value is the result a method sends back to the part of the program that called it. It lets the method give information after it finishes running.
touch_appClick to reveal answer
beginner
How do you specify the type of value a method returns in Java?
You write the type before the method name in its declaration. For example,
int means the method returns an integer number.touch_appClick to reveal answer
intermediate
What happens if a method has a return type other than
void but does not use a return statement?The program will not compile. Java requires that all paths in such a method return a value matching the declared type.
touch_appClick to reveal answer
intermediate
Can a method return multiple values directly in Java?
No, a method can return only one value. To return multiple values, you can use an object or an array to hold them.
touch_appClick to reveal answer
beginner
What does the
void keyword mean in a method declaration?It means the method does not return any value. It just runs its code and finishes without sending anything back.
touch_appClick to reveal answer
What keyword is used to send a value back from a method in Java?
If a method is declared as
int calculate(), what must it do?What will happen if a method with return type
double does not have a return statement?Which of these methods does NOT return a value?
How can a method return multiple values in Java?
Explain what a return value is and why it is useful in Java methods.
Describe the difference between a method with a
void return type and one with a specific return type.