Boolean Basics
Choose Your Path
Inside Another If
Combine the Conditions
Same Logic Different Look
100

What are the only two values a Java boolean can store?

true and false

100

What prints?

int points = 14;
if (points >= 10)
    System.out.println("Bonus");
else
    System.out.println("Keep trying");

Bonus

100

What makes a selection statement nested?

An if or if-else statement appears inside another selection statement’s branch.

100

Which Java operator means logical AND?

&&

100

Simplify !!ready

ready

200

If int tickets = 12;, what is the value of tickets >= 12?

true

200

int age = 15;
if (age < 13)
    System.out.println("Child");
else if (age < 18)
    System.out.println("Teen");
else
    System.out.println("Adult");

Teen

200

What prints?

boolean member = true;
int visits = 6;

if (member) {
    if (visits >= 5)
        System.out.println("Free pass");
    else
        System.out.println("Member price");
} else {
    System.out.println("Regular price");
}

Free pass

200

Evaluate the expression.

int temperature = 72;
boolean raining = false;

temperature > 65 && !raining

true

200

Rewrite !(score < 70) without using !

score >= 70

300

Write a Boolean expression that checks whether score is not equal to 100.

score != 100

300

int level = 2;
if (level > 5)
    System.out.print("Gold ");
System.out.print("Player");

Player

300

What prints?

int age = 14;
boolean adultPresent = true;

if (age >= 16) {
    System.out.println("Enter alone");
} else {
    if (adultPresent)
        System.out.println("Enter with adult");
    else
        System.out.println("Wait outside");
}

Enter with adult

300

Write a Boolean expression that is true when height is at least 48 and at most 78.

height >= 48 && height <= 78

300

Rewrite !(sunny && warm) using De Morgan’s Law

!sunny || !warm

400

What value is stored in result?

int a = 7;
int b = 2;
boolean result = (a / b == 3);

true

Integer division makes 7 / 2 equal to 3

400

int n = 4;
if (n > 2)
    n += 3;
if (n > 6)
    n--;
else
    n += 2;
System.out.println(n);

6

400

What prints? 

int x = 9;
int y = 2;

if (x > 5)
    if (y > 4)
        System.out.println("A");
    else
        System.out.println("B");

B

400

When is my daughter's birthday?

September 14th, 2025
400

Rewrite !(age < 12 || age >= 65) without using !

age >= 12 && age < 65


500

Write a statement that creates a Boolean variable named hasCat, which is true when the String variable message contains "cat". Use indexOf.

boolean hasCat = message.indexOf("cat") >= 0;

500

Fix the code so it prints "Even" for even integers and "Odd" otherwise.

int number = 8;
if number % 2 = 0)
    System.out.println("Even")
else
    System.out.println("Odd");

Change the = to ==

need opening (

need semicolon

500

Write nested selection statements for this rule:

If balance >= 20, print "Discount purchase" when hasCoupon is true and "Regular purchase" otherwise. If balance < 20, print "Save more".

if (balance >= 20) {

    if (hasCoupon)

        System.out.println("Discount purchase");

    else

        System.out.println("Regular purchase");

} else {

    System.out.println("Save more");

}

500

Write an if-else statement that prints "Access granted" when a person has a ticket OR is a volunteer, but only if they are NOT banned. Otherwise, print "Access denied".

Use hasTicket, volunteer, and banned.

if ((hasTicket || volunteer) && !banned)
    System.out.println("Access granted");
else
    System.out.println("Access denied");

500

Are !(a && b) and !a && !b equivalent? If not, give values that prove it

No. For a = true and b = false, the first expression is true, but the second is false.

M
e
n
u