Unit 2 · Selection and Iteration
If/Else Tracing
Practice mode with 15 Java-focused questions, immediate answer checks, and explanations.
What if/else tracing covers
In an if / else if / else chain, Java tests conditions in order and executes only the first branch whose condition is true, skipping the rest entirely. Independent if statements behave differently: each one is tested, so more than one body can run. Without braces, an if controls only the single statement that follows it, and the next line runs unconditionally regardless of indentation.
Where students lose points
Students trace an else-if chain as though every condition is checked, which produces the wrong output whenever two conditions overlap. The second trap is trusting indentation over braces, since Java ignores whitespace. Condition order also matters: putting a broad condition before a narrow one makes the narrow branch unreachable.
How it shows up on the AP exam
Unit 2 selection, and one of the highest-frequency code-tracing formats on the MCQ. It also drives FRQ scoring, where an unreachable branch loses the point even when the logic inside it is correct.
For practice use only.
If/Else Tracing MCQ Practice
AP CSA if/else tracing practice: which branch actually runs, why else-if chains stop at the first match, and how missing braces change control flow.
Answered 0 of 15
Choose one answer.
Which option matches the complete output produced by this segment?
public class IfElseTracingContext
{
public static void runExample()
{
int score = 70;
if (score > 70)
{
System.out.print("high");
}
else
{
System.out.print("low");
}
}
public static void main(String[] args)
{
runExample();
}
}