if Statements FRQ Practice

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

Question 1 of 5

A radio desk should print live only when signal is strictly greater than 50.

(a) Write a one-way if that prints live only when signal > 50. (b) State the displayed text from that if when signal is 50. (c) Explain why that body does not run when the condition is false.

Question 2 of 5

Complete the missing table cells for this parking check.

int minutes = /* table value */;
if (minutes > 30)
    System.out.print("pay");
else
    System.out.print("free");
minutes Condition minutes > 30 Displayed text
45 true pay
30
0

(a) Fill the empty cells. (b) Explain why 30 minutes uses the else branch. (c) State which branch runs when the condition is true.

Question 3 of 5

A seed drawer uses this unbraced if.

int seeds = 2;
if (seeds > 5)
    seeds = 9;
    seeds = 0;

(a) State the value stored in seeds after this code runs. (b) Identify which assignment always runs because it is not the if body. (c) Rewrite with braces so both assignments run only when seeds > 5, and state the resulting value of seeds starting from 2.

Question 4 of 5

Compare one-way selection M with two-way selection N.

Code M:

if (tide > 4)
    System.out.print("high");
System.out.print("note");

Code N:

if (tide > 4)
    System.out.print("high");
else
    System.out.print("low");

(a) State the displayed text for M and for N when tide is 7. (b) State the displayed text for M and for N when tide is 4. (c) Explain the difference between an always-running statement after a one-way if and an else body.

Question 5 of 5

Trace this pair of selections by hand.

int u = 25;
int v = 8;
if (u / v > 3)
{
    u = 1;
}
else
{
    v = v - 3;
}
if (u > v)
    System.out.print(u);
else
    System.out.print(v);

(a) State the integer value of u / v and which first branch runs. (b) State the values of u and v after the first selection. (c) State the displayed text. (d) Explain how truncation affected which first branch ran.