AP CSA Unit 2 Day 5: Boolean Precedence Andand Before
Share
Unit 2, Selection & Iteration • Cycle 2
Day 5 Advanced Practice • Harder Difficulty
Focus: Operator Precedence
Hard
Boolean Precedence (&& before ||)
Advanced Practice Question
Format: Boolean Precedence (&& before ||)
What is printed?
What is printed?
boolean a = true;
boolean b = false;
boolean c = true;
System.out.println(a || b && c);
Difficulty: Hard |
Topic: Boolean Precedence (&& before ||) |
Cycle: 2 (Advanced)
Why This Answer?
`a > 3` is false. `b / a` is `7 / 3` which is 2 (integer division), so `(b / a == 2)` is true. `b % a` is 1, so `(b % a == 1)` is true. `true && true` is true, so `false || true` is true.
Common Mistake
Watch Out!
Evaluating left-to-right and treating `||` as having the same precedence as `&&`.
AP Exam Strategy
Remember: `&&` groups tighter than `||` unless parentheses force a different grouping.
Master This Topic
This Cycle 2 HARD question tests operator precedence. Review Unit 2 concepts to build mastery of selection and iteration.
- Understanding operator precedence
- 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