Unit 2 Cycle 2 Day 4: Selection (Nested if / else)

Unit 2, Selection & Iteration • Cycle 2
Day 4 Advanced Practice • Harder Difficulty
Focus: Nested Conditionals Hard Selection (Nested if / else)

Advanced Practice Question

Format: Selection (Nested if / else)

What is printed?
"apcs-keyword">int x = "apcs-number">4;
"apcs-keyword">int y = "apcs-number">2;

"apcs-keyword">if (x > "apcs-number">3)
{
    "apcs-keyword">if (y > "apcs-number">3)
    {
        System.out.print("A");
    }
    else
    {
        System.out.print("B");
    }
}
else
{
    System.out.print("C");
}
Difficulty: Hard  |  Topic: Selection (Nested if / else)  |  Cycle: 2 (Advanced)
Why This Answer?

`x > 3` is true, so the inner `if` runs. `y > 3` is false, so it prints `B`.

Common Mistake
Watch Out!

Forgetting the inner condition still matters once you enter the outer block.

AP Exam Strategy

Trace outer condition first, then evaluate the inner condition only if you enter the block.

Master This Topic

This Cycle 2 HARD question tests nested conditionals. Review Unit 2 concepts to build mastery of selection and iteration.

  • Understanding nested conditionals
  • Tracing code execution accurately
  • Avoiding common pitfalls
View Unit 2 Study Guide

Ready for More Challenges?

Cycle 2 questions prepare you for the hardest AP CSA exam questions.

Study Games Practice FRQs
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.