Compound Assignment Operators MCQ Practice

Question 1 of 10

A garden inventory removes used seed packs. What text does this Java code display?

int packs = 27;
packs -= 8;
System.out.print(packs);
  1. A. 35
  2. B. 8
  3. C. 19
  4. D. 27

Question 2 of 10

Each tray is copied onto 7 shelves. What text does this Java code display?

int trays = 4;
trays *= 7;
System.out.print(trays);
  1. A. 11
  2. B. 28
  3. C. 3
  4. D. 7

Question 3 of 10

Seedlings are grouped into rows of 7. What text does this Java code display?

int leftover = 31;
leftover %= 7;
System.out.print(leftover);
  1. A. 4
  2. B. 3
  3. C. 24
  4. D. 7

Question 4 of 10

Soil mass is recorded as a double. What text does this Java code display?

double mass = 2.5;
mass += 1.75;
System.out.print(mass);
  1. A. 4.25
  2. B. 1.75
  3. C. 2.5
  4. D. 0.75

Question 5 of 10

Catalog pages are split among 8 binders using int division. What text does this Java code display?

int pages = 50;
pages /= 8;
System.out.print(pages);
  1. A. 6.25
  2. B. 7
  3. C. 6
  4. D. 8

Question 6 of 10

A plot counter is updated, then multiplied by its own stored value. What text does this Java code display?

int plots = 3;
plots += 5;
plots *= plots;
System.out.print(plots);
  1. A. 24
  2. B. 8
  3. C. 15
  4. D. 64

Question 7 of 10

Which description of owed += fee; is accurate for simple numeric variables?

  1. A. Java locates owed once, adds fee to that stored value, and writes the sum back into owed.
  2. B. Java locates fee twice and never reads owed.
  3. C. Java computes owed + fee but does not assign unless = is written separately.
  4. D. Java replaces owed with fee and discards the old owed value without adding.

Question 8 of 10

A kiln cools by one degree, then a guard adds fuel. What text does this Java code display?

int heat = 12;
heat--;
heat += 4;
System.out.print(heat);
  1. A. 15
  2. B. 16
  3. C. 8
  4. D. 11

Question 9 of 10

A volunteer needs to replace rain = rain % 10; with a compound assignment. Which statement is equivalent?

  1. A. rain += 10;
  2. B. rain /= 10;
  3. C. rain *= 10;
  4. D. rain %= 10;

Question 10 of 10

A hose length is scaled, then shortened. What text does this Java code display?

double length = 8.0;
length *= 0.5;
length -= 1.0;
System.out.print(length);
  1. A. 3.0
  2. B. 4.0
  3. C. 7.5
  4. D. 2.5