int n = 5;
while (n > 0) {
System.out.println(n);
n++;
}What happens?
- A
prints 5 once
- B
prints nothing
- C
prints 5 4 3 2 1
- Dcheck_circle
infinite loop (until int overflow)
Explanation
n starts at 5 and only increases (n++). The condition n > 0 stays true forever (until int overflow wraps to a negative value far in the future). This is an infinite loop bug — likely the author meant n--.