AP CSA Unit 2.2: Boolean Expressions and Logical Operators Practice

Unit 2, Section 2.2
Day 2 Practice • January 8, 2026
🎯 Focus: Boolean Expressions

Practice Question

Consider the following code segment:
int x = 7;
int y = 10;
boolean a = x < y;
boolean b = x == 7;
boolean c = a && b;
System.out.println(c);
What is printed as a result of executing this code segment?

What This Tests: Section 2.2 covers Boolean expressions—expressions that evaluate to true or false. This question tests relational operators (<, ==) and the logical AND operator (&&).

Key Concept: Boolean Operators

// Relational operators (compare values)
<   // less than
>   // greater than
<=  // less than or equal
>=  // greater than or equal
==  // equal to (note: TWO equals signs)
!=  // not equal to

// Logical operators (combine booleans)
&&  // AND: true only if BOTH are true
||  // OR: true if EITHER is true
!   // NOT: flips true↔false

Step-by-Step Trace

Line Expression Evaluation Result
3 a = x < y 7 < 10 true
4 b = x == 7 7 == 7 true
5 c = a && b true && true true

AND Truth Table

a b a && b
true true true
true false false
false true false
false false false

Remember: AND (&&) requires BOTH to be true!

Common Mistakes

Mistake: Answer C or D (1 or 0)

Java booleans print as "true" or "false", not 1 or 0. Unlike some other languages, Java distinguishes between boolean and integer types.

Mistake: Using = instead of ==

Single equals (=) is assignment. Double equals (==) is comparison. x == 7 checks if x equals 7.

Related Topics

  • Section 2.3: if Statements (using boolean conditions)
  • Section 2.5: Compound Boolean Expressions
  • Section 2.6: Equivalent Boolean Expressions
Difficulty: Medium • Time: 2-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

400+ Unit 2 questions • Expert tutoring • 5.0 rating

Back to blog

Leave a comment

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