Compound Assignment Operators

AP Computer Science A· difficulty 2/5

int x = 10;
x += 3;
x *= 2;
System.out.println(x);

What is printed?

  • A

    26

    check_circle
  • B

    20

  • C

    23

  • D

    16

Explanation

x += 3 makes x equal to 13, then x *= 2 makes x equal to 26.

Want 10 more like this — adaptive to your weak spots?

Related questions