Compound Boolean Expressions FRQ Practice

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

Question 1 of 5

A carnival booth stores two flags and then evaluates compound booleans.

boolean rain = true;
boolean wind = false;

(a) State the value of rain && wind. (b) State the value of rain || wind. (c) State the value of !wind && rain, and explain why && can be false while || is true for the same pair of flags.

Question 2 of 5

Complete the missing values for this evaluation. Then explain why && is applied before ||.

boolean a = false;
boolean b = true;
boolean c = true;
boolean result = !a && b || c;
Subexpression Value
!a
!a && b
(!a && b) || c

Question 3 of 5

The method mark prints M when it runs. Trace this kiln check.

public boolean mark()
{
    System.out.print("M");
    return true;
}

int n = 0;
System.out.print((n > 0) && (8 / n > 1) || mark());

(a) Is 8 / n evaluated? Explain using short-circuit rules. (b) Is mark called? Explain. (c) State the exact text displayed.

Question 4 of 5

A ticket window uses this unparenthesized expression.

!ready || full && late

Use ready = false, full = true, and late = false.

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

Question 5 of 5

The method spark prints K when it runs. Trace this kiln controller.

public boolean spark()
{
    System.out.print("K");
    return false;
}

int vents = 0;
boolean hot = true;
boolean go = hot || spark() && (12 / vents > 1);
System.out.print(go);

(a) Parenthesize spark() && (12 / vents > 1) with hot || ... according to Java precedence. (b) Identify which of spark and the division are skipped, and why. (c) State the exact text displayed. (d) If hot were false instead, state whether spark would run and whether 12 / vents would run.