Compound Assignment Operators MCQ Practice

Question 1 of 10

A prize booth tracks unused stickers. What text does this Java code display?

int stickers = 14;
stickers += 9;
System.out.print(stickers);
  1. A. 14
  2. B. 23
  3. C. 9
  4. D. 15

Question 2 of 10

A shuttle logs remaining fuel units. What text does this Java code display?

int fuel = 40;
fuel -= 17;
System.out.print(fuel);
  1. A. 57
  2. B. 17
  3. C. 40
  4. D. 23

Question 3 of 10

A warehouse restacks identical cartons. What text does this Java code display?

int cartons = 6;
cartons *= 5;
System.out.print(cartons);
  1. A. 30
  2. B. 11
  3. C. 6
  4. D. 5

Question 4 of 10

Ribbon is cut into equal 5-centimeter pieces. What text does this Java code display?

int ribbon = 23;
ribbon /= 5;
System.out.print(ribbon);
  1. A. 4.6
  2. B. 5
  3. C. 4
  4. D. 3

Question 5 of 10

The leftover ribbon after making 5-centimeter pieces is needed. What text does this Java code display?

int ribbon = 23;
ribbon %= 5;
System.out.print(ribbon);
  1. A. 4
  2. B. 3
  3. C. 18
  4. D. 0

Question 6 of 10

A recipe scales a double volume. What text does this Java code display?

double syrup = 9.0;
syrup /= 4;
System.out.print(syrup);
  1. A. 2
  2. B. 2.25
  3. C. 36.0
  4. D. 9.0

Question 7 of 10

Compound assignment identifies the left-hand variable once, then stores the updated value there. What text does this Java code display?

int tokens = 11;
tokens += tokens;
System.out.print(tokens);
  1. A. 11
  2. B. 0
  3. C. 22
  4. D. 12

Question 8 of 10

A contest score is updated in order. What text does this Java code display?

int score = 5;
score += 3;
score *= 4;
score -= 2;
System.out.print(score);
  1. A. 30
  2. B. 18
  3. C. 32
  4. D. 26

Question 9 of 10

A lane counter uses a standalone postfix increment. What text does this Java code display?

int lane = 7;
lane++;
System.out.print(lane);
  1. A. 6
  2. B. 7
  3. C. 8
  4. D. 1

Question 10 of 10

Consider this code:

int n = 20;
n /= 6;

Which statement is true about the value stored in n?

  1. A. n stores 3 because int division truncates toward zero before the result is assigned.
  2. B. n stores 3.333... because /= always keeps a fractional quotient.
  3. C. n is unchanged because /= computes a value without assigning it.
  4. D. n stores 6 because the operator copies the right operand.