Unit 2 Cycle 2 Day 16: Selection (if / else-if boundary)
Share
Unit 2, Selection & Iteration • Cycle 2
Day 16 Advanced Practice • Harder Difficulty
Focus: Conditional Chain
Hard
Selection (if / else-if boundary)
Advanced Practice Question
Format: Selection (if / else-if boundary)
What is printed?
What is printed?
"apcs-keyword">int n = "apcs-number">0;
"apcs-keyword">if (n >= "apcs-number">1)
{
System.out.print("A");
}
"apcs-keyword">else "apcs-keyword">if (n >= "apcs-number">0)
{
System.out.print("B");
}
else
{
System.out.print("C");
}
Difficulty: Hard |
Topic: Selection (if / else-if boundary) |
Cycle: 2 (Advanced)
Why This Answer?
`n >= 1` is false. `n >= 0` is true, so it prints `B`.
Common Mistake
Watch Out!
Assuming the first false condition ends the chain (it does not).
AP Exam Strategy
In an if/else-if chain, the first true branch runs; earlier false branches don't stop evaluation.
Master This Topic
This Cycle 2 HARD question tests conditional chain. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding conditional chain
- Tracing code execution accurately
- Avoiding common pitfalls
Ready for More Challenges?
Cycle 2 questions prepare you for the hardest AP CSA exam questions.
Study Games Practice FRQs