Unit 3 · Class Creation
Methods and Parameters
Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.
What methods and parameters covers
Java passes everything by value. For a primitive, the method receives a copy of the number, so changing the parameter has no effect on the caller. For an object or array, the method receives a copy of the reference, which still points at the same underlying object. That means the method can mutate the object through it, but reassigning the parameter to a new object only changes the local copy.
Where students lose points
The single most consequential misconception on the exam is expecting a method to change a caller's int or a caller's String. Students also assume that because arrays can be mutated by a method, reassigning the array parameter will be visible outside, which it is not.
How it shows up on the AP exam
Unit 3 class creation, and the concept behind a large family of trace-the-output questions. It also explains why String swap methods cannot work, a perennial MCQ answer choice.
For practice use only.
Methods and Parameters MCQ Practice
AP CSA methods and parameters practice: pass by value, why primitive changes do not escape, and how object references let a method mutate shared state.
Answered 0 of 15
Choose one answer.
Which option matches the complete output produced by this segment?
public class MethodsAndParametersContext
{
public static int twice(int n)
{
return n * 2;
}
public static void main(
String[] args)
{
System.out.print(twice(3) + twice(4));
}
}