Unit 2 Cycle 2 Day 17: Boolean Precedence (&& with ||)

Unit 2, Selection & Iteration • Cycle 2
Day 17 Advanced Practice • Harder Difficulty
Focus: Operator Precedence Hard Boolean Precedence (&& with ||)

Advanced Practice Question

Format: Boolean Precedence (&& with ||)

What is printed?
"apcs-keyword">int a = "apcs-number">4;
"apcs-keyword">int b = "apcs-number">5;

"apcs-keyword">boolean r = (a < b) && (a + b == "apcs-number">9) || (a == "apcs-number">0);

System.out.println(r);
Difficulty: Hard  |  Topic: Boolean Precedence (&& with ||)  |  Cycle: 2 (Advanced)
Why This Answer?

`a < b` is true and `a + b == 9` is true, so `(true && true)` is true. `a == 0` is false. `true || false` is true.

Common Mistake
Watch Out!

Forgetting that `&&` is evaluated before `||` unless parentheses change it.

AP Exam Strategy

If you're unsure, rewrite as: `((a < b) && (a + b == 9)) || (a == 0)`.

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
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.