AP CSA Unit 2 Day 7: Selection Two Separate If Statements
Share
Unit 2, Selection & Iteration • Cycle 2
Day 7 Advanced Practice • Harder Difficulty
Focus: Independent If Statements
Hard
Selection (Two separate if statements)
Advanced Practice Question
Format: Selection (Two separate if statements)
What is printed?
What is printed?
int x = 10;
if (x > 5) {
System.out.println("A");
}
if (x < 15) {
System.out.println("B");
}
Difficulty: Hard |
Topic: Selection (Two separate if statements) |
Cycle: 2 (Advanced)
Why This Answer?
`12` is divisible by 3, so it prints `X`. It is also divisible by 4, so it prints `Y`. The `else` does not run because the second `if` was true.
Common Mistake
Watch Out!
Thinking the second `if` is connected to the first one (it is not).
AP Exam Strategy
If there are two separate `if`s, they are evaluated independently.
Master This Topic
This Cycle 2 HARD question tests independent if statements. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding independent if statements
- 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