Given:
public class DoWhile {
public static void main (String [] args) {
int ii = 2;
do {
System.out.println (ii);
} while (–ii);
}
}
What is the result?
A.
2
1
B.
2
1
0
C.
null
D.
an infinite loop
E.
compilation fails
Explanation:
The line while (–ii); will cause the compilation to fail.
–ii is not a boolean value.
A correct line would be while (–ii>0);