Compound Boolean Expressions FRQ Practice

Responses receive AI feedback against a rubric after submission. Scores are practice estimates.

Question 1 of 5

A museum wing stores two flags.

boolean quiet = false;
boolean staff = true;

(a) State the value of quiet || staff. (b) State the value of quiet && staff. (c) State the value of !quiet && staff and explain how ! changes the && result compared with part (b).

Question 2 of 5

Complete the missing values. Then name the operator evaluated first after any !.

boolean x = true;
boolean y = false;
boolean z = false;
boolean result = x || y && !z;
Subexpression Value
!z
y && !z
x || (y && !z)

Question 3 of 5

The method scan prints Q when it runs. Trace this archive check.

public boolean scan()
{
    System.out.print("Q");
    return false;
}

int bins = 0;
System.out.print(scan() || (bins != 0) && (15 / bins > 2));

(a) Why does scan run even though there is a || later in the line? (b) Is 15 / bins evaluated? Explain. (c) State the exact text displayed.

Question 4 of 5

A marina gate uses this unparenthesized expression.

!a && b || c

Use a = true, b = false, and c = true.

(a) Rewrite the expression with parentheses that show Java's grouping. (b) Evaluate that grouped expression. (c) Evaluate !a && (b || c) and explain why the two results differ.

Question 5 of 5

The method flare prints F when it runs. Trace this well sensor.

public boolean flare()
{
    System.out.print("F");
    return true;
}

int depth = 0;
boolean dry = false;
boolean ok = dry && flare() || (depth == 0) || (8 / depth > 1);
System.out.print(ok);

(a) Parenthesize the expression according to Java precedence and left-to-right ||. (b) Is flare called? Explain. (c) Is 8 / depth evaluated? Explain. (d) State the exact text displayed.