AP CSA Unit-Level MCQ
Code Tracing: Classes and Constructors
Practice mode with 50 Java-focused questions, immediate answer checks, and explanations.
For practice use only.
Code Tracing: Classes and Constructors MCQ Practice
Code Tracing: Classes and Constructors AP Computer Science A topic practice with 50 original Java MCQs and immediate explanations.
Question 1 of 50
Answered 0 of 50
Choose one answer.
What is printed by this Classes and Constructors code trace?
public class Main {
public static void main(String[] args) {
Tracker t = new Tracker(18);
t.add(3);
t.add(5);
System.out.print(t.getValue());
}
}
class Tracker {
private int value;
public Tracker(int start) { value = start; }
public void add(int amount) { value += amount; }
public int getValue() { return value; }
}