Expressions and Assignment Statements

AP Computer Science A· difficulty 2/5

int a = 17;
int b = 5;
System.out.println(a % b);

What is printed?

  • A

    2

    check_circle
  • B

    3

  • C

    3.4

  • D

    0

Explanation

17 % 5 returns the remainder of 17 / 5, which is 2 (since 5 * 3 = 15 and 17 - 15 = 2).

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

Related questions