Compound Assignment Operators FRQ Practice

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

Question 1 of 5

A carnival booth starts with this code:

int tickets = 16;
tickets = tickets + 4;
tickets = tickets * 2;
tickets = tickets - 5;

(a) Rewrite the three updates using compound assignment operators. (b) State the final value of tickets. (c) Explain how *= is different from writing tickets + 2 without assignment.

Question 2 of 5

Complete the missing results for this booth register. Then explain why the /= step does not store 7.5.

Step Statement Value of chips after the statement
1 int chips = 10; 10
2 chips += 5;
3 chips *= 3;
4 chips /= 6;
5 chips %= 4;

Question 3 of 5

Java evaluates the left-hand side of a compound assignment once, then stores the computed result in that same variable.

int pile = 8;
pile += pile;

(a) Identify the variable that is located once on the left. (b) State the value stored in pile afterward. (c) Write an equivalent simple assignment that uses pile on both sides, and explain why the two forms match for this simple variable.

Question 4 of 5

A clerk must keep only leftover beads after grouping them by 7.

(a) Write Java that starts beads at 26 and then uses %= so beads stores the leftover count. (b) State the leftover value. (c) Explain why %= is the operator that matches this task rather than /=.

Question 5 of 5

Compare these two updates:

int whole = 11;
whole /= 2;
double mix = 11.0;
mix /= 2;

(a) State the value stored in whole and the value stored in mix. (b) Explain how the type of the left-hand variable affects the stored result. (c) Write one additional compound assignment that uses mix and stores 8.5.