int a = -17;
int b = 5;
System.out.println(a % b);What is printed?
- Acheck_circle
-2
- B
3
- C
2
- D
-3
Explanation
In Java, the result of % takes the sign of the dividend; -17 % 5 = -2 because -17 = 5 * (-3) + (-2).
AP Computer Science A· difficulty 4/5
int a = -17;
int b = 5;
System.out.println(a % b);What is printed?
-2
3
2
-3
Explanation
In Java, the result of % takes the sign of the dividend; -17 % 5 = -2 because -17 = 5 * (-3) + (-2).
Want 10 more like this — adaptive to your weak spots?