Compound Assignment Operators

AP Computer Science A· difficulty 2/5

int n = 20;
n /= 6;
System.out.println(n);

What is printed?

  • A

    3

    check_circle
  • B

    3.33

  • C

    2

  • D

    4

Explanation

n /= 6 sets n to n / 6 with integer division, so 20 / 6 = 3.

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

Related questions