AP CSA Unit 1.6: Compound Assignment Operators Practice

Unit 1, Section 1.6
Day 6 Practice • January 12, 2026
🎯 Focus: Compound Assignment Operators

Practice Question

Consider the following code segment:
int x = 10;
x += 5;
x *= 2;
x -= 8;
System.out.println(x);
What is printed as a result of executing this code segment?

What This Tests: Section 1.6 covers compound assignment operators (+=, -=, *=, /=, %=). These shortcuts modify a variable using its current value. Understanding them is essential because they appear frequently on the AP exam.

Key Concept: Compound Operators

x += 5;   // Same as: x = x + 5;
x -= 3;   // Same as: x = x - 3;
x *= 2;   // Same as: x = x * 2;
x /= 4;   // Same as: x = x / 4;
x %= 3;   // Same as: x = x % 3;

Step-by-Step Trace

Line Code Equivalent x
1 int x = 10; - 10
2 x += 5; x = 10 + 5 15
3 x *= 2; x = 15 * 2 30
4 x -= 8; x = 30 - 8 22

Output: 22

Common Mistakes

Mistake: Answer A (12)

This might come from doing 10 + 5 - 8 = 7 then something with *2. Order matters—trace each line sequentially!

Mistake: Answer E (30)

This forgets the last operation (x -= 8). After x *= 2, x is 30, but then we subtract 8 to get 22.

Increment/Decrement

Special Cases: ++ and --

x++; is the same as x += 1; or x = x + 1;

x--; is the same as x -= 1; or x = x - 1;

Related Topics

  • Section 1.4: Assignment Statements
  • Section 2.7: while Loops (often use ++)
  • Section 2.8: for Loops (often use ++)
Difficulty: Medium • Time: 2 minutes • AP Skill: 2.A - Apply operators

Ready to Level Up Your AP CSA Skills?

Get personalized help or access our complete question bank

Premium Question Bank - Coming Soon! Schedule 1-on-1 Tutoring

300+ Unit 1 questions • Expert tutoring • 5.0 rating

Back to blog

Leave a comment

Please note, comments need to be approved before they are published.