Sample QOTD

Unit 2 - Day 5

Compound Boolean Expressions

AP CSA 2025-26 Medium Difficulty ~3 min
Consider the following code segment.
int x = 7; int y = 3; boolean result = (x > 5) && (y < 5) || (x == y); System.out.println(result);
A)
B)
C)
D)

Why A is correct:

The expression evaluates step by step: (x > 5) is true, (y < 5) is true. true && true gives true. Since the first part of the || is already true, the entire expression is true.

Why the other options are wrong:

A) This is correct - see explanation above.

B) This would only be correct if both conditions in the && were false, or if the && result was false AND (x == y) was also false.

C) The code is syntactically correct. Boolean expressions with && and || are valid in Java.

D) There is no operation here that could cause a runtime error (no division, no array access, no null reference).

AP Exam Tip

Remember operator precedence: && is evaluated before ||. Always trace compound boolean expressions step by step, evaluating each part separately before combining.

Keep Building Your Skills!

Consistent daily practice is the key to AP CSA success.

Practice FRQs Study Games

Get in Touch

Whether you're a student, parent, or teacher — I'd love to hear from you.

Just want free AP CS resources?

Enter your email below and check the subscribe box — no message needed. Students get daily practice questions and study tips. Teachers get curriculum resources and teaching strategies.

Typically responds within 24 hours

Message Sent!

Thanks for reaching out. I'll get back to you within 24 hours.

🏫 Welcome, fellow educator!

I offer curriculum resources, practice materials, and study guides designed for AP CS teachers. Let me know what you're looking for — whether it's classroom materials, a guest speaker, or Teachers Pay Teachers resources.

Email

[email protected]

📚

Courses

AP CSA, CSP, & Cybersecurity

Response Time

Within 24 hours

Prefer email? Reach me directly at [email protected]