Unit 3 · Class Creation
Return Values
Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.
What return values covers
A return statement produces a value and immediately exits the method, so any code after it in that path never runs. Every path through a value-returning method must return something of the declared type; a void method returns no value and calling it in an expression does not compile. Returning a value is not the same as printing it, and a returned value is lost unless the caller stores or uses it.
Where students lose points
Calling a method and discarding its result, then expecting the caller's variable to have changed, is the classic error, and it is the same misunderstanding that drives the String immutability trap. Students also write returns inside an if without a fall-through return, and they print inside a method that the question expected to return.
How it shows up on the AP exam
Unit 3 content that determines whether an FRQ method header is implemented correctly at all. A method that prints instead of returning generally scores zero on that part regardless of the logic inside.
For practice use only.
Return Values MCQ Practice
AP CSA return value practice: what return actually does, void versus value-returning methods, ignored results, and return type matching.
Answered 0 of 15
Choose one answer.
Which option matches the complete output produced by this segment?
public class ReturnValuesContext
{
public static int pick(int n)
{
if (n > 0)
{
return 1;
}
return -1;
}
public static void main(
String[] args)
{
System.out.print(pick(0));
}
}