AP CSA Unit 2.5: Compound Boolean Expressions Practice

Unit 2, Section 2.5
Day 5 Practice • January 11, 2026
🎯 Focus: Compound Boolean Expressions

Practice Question

Consider the following code segment:
int age = 25;
boolean hasLicense = true;
boolean hasInsurance = false;

boolean canDrive = hasLicense && (age >= 16 || hasInsurance);
System.out.println(canDrive);
What is printed as a result of executing this code segment?

What This Tests: Compound boolean expressions combine && (AND) and || (OR). Parentheses are evaluated first, then &&, then ||.

Step-by-Step Trace

hasLicense && (age >= 16 || hasInsurance)
= true && (25 >= 16 || false)   // substitute values
= true && (true || false)       // 25 >= 16 is true
= true && true                  // true OR false = true
= true                          // true AND true = true

Operator Precedence

Order of Evaluation
  1. Parentheses () first
  2. NOT (!) next
  3. AND (&&) before OR
  4. OR (||) last

Common Mistakes

Mistake: Answer B (false)

This might come from thinking hasInsurance = false makes the whole thing false. But the OR only needs ONE side to be true, and age >= 16 is true.

Difficulty: Medium • Time: 3 minutes • AP Skill: 2.B - Determine boolean results

Ready to Level Up Your AP CSA Skills?

Get personalized help or access our complete question bank

Premium Question Bank - Coming Soon Schedule 1-on-1 Tutoring
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.