int x = -1;
int y = 0;
if (x > 0)
y++;
y++;
System.out.println(y);What is printed?
- A
2
- B
-1
- Ccheck_circle
1
- D
0
Explanation
The if controls only the first y++. With x = -1, that one is skipped. The second y++ is NOT inside the if (despite the indentation), so it always runs. y = 1.