for Loops FRQ Practice

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

Question 1 of 5

A starter chant uses this loop:

for (int h = 0; h < 3; h++) {
    System.out.print("go");
}

(a) Identify the initialization, Boolean expression, and update. (b) How many times does initialization run? How many times does the update run? (c) State the displayed text and how many times the Boolean is true.

Question 2 of 5

Complete the missing trace cells. Then state the final value of load.

int load = 10;
for (int crate = 2; crate <= 6; crate += 2) {
    load -= crate;
}
Body crate at body start load after body crate after update crate <= 6 for next test?
1 2
2
3

Question 3 of 5

Rewrite this while loop as an equivalent for loop. Then state the displayed text.

int m = 4;
while (m <= 10) {
    System.out.print(m);
    m += 3;
}

Also explain one difference in where m can be used after each version finishes.

Question 4 of 5

Write a for loop that displays 54321 using a decreasing loop control variable and System.out.print.

(a) Write the loop. (b) State how many times the Boolean is true and how many times it is tested in all. (c) Write the equivalent while loop.

Question 5 of 5

These two fragments are meant to match:

int p = 0;
for (int i = 1; i < 4; i++) {
    p += i;
}
int q = 0;
int j = 1;
while (j < 4) {
    q += j;
    j++;
}

(a) Trace both loops and show that p and q match. Also state the value of j after the while, and whether i is in scope after the for. (b) If the while forgot j++, what would happen? (c) If the for Boolean were changed to i <= 4, give the new p and explain the off-by-one versus the original while.