In the first iteration m is 0 and after the condition is checked it becomes 1 because of m++. So, this prints 1.
Now second iteration starts and this time m is 1 so, condition is true and m++ gets executes. now m contains 2 and enters into loop. so, prints 2. Now again iteration starts. m is 2 and 2 is not less than 2 so it comes out of the loop.
I hope this might help u
Bye
with regards
chak
Originally posted by Randall Twede:
29. For the code:
m = 0;
while( m++ < 2 ) /* in the first iteration m is 0
System.out.println( m );
Which of the following are printed to standard output?
a) 0
b) 1
c) 2
d) 3
e) Nothing and an exception is thrown
[\QUOTE]
I answered a and b but correct answers were b and c.
I think they are right but could someone explain a little bit for me.