int x = 5;
if (x > 0 || x++ > 100) {
System.out.println(x);
}What is printed?
- Acheck_circle
5
- B
6
- C
0
- D
100
Explanation
Short-circuit ||: x > 0 is true (5 > 0), so the right-hand expression x++ is NOT evaluated. x remains 5.
AP Computer Science A· difficulty 3/5
int x = 5;
if (x > 0 || x++ > 100) {
System.out.println(x);
}What is printed?
5
6
0
100
Explanation
Short-circuit ||: x > 0 is true (5 > 0), so the right-hand expression x++ is NOT evaluated. x remains 5.
Want 10 more like this — adaptive to your weak spots?