What will be the output if you run the following program?
public class Main{ public static void main (String args []){ int i; /*from w w w . j a v a2 s. c o m*/ int j; for(i = 0, j = 0 ; j < 1 ; ++j , i++){ System.out.println ( i + " " + j ); } System.out.println ( i + " " + j ); } }
Select 1 option
Correct Option is : D
j will be less than 1 for only the first iteration.
So, first it will print 0, 0.
Next, i and j are incremented.
Because j is not less than 1 at the start of the loop,
the condition fails and it comes out of the loop.
Finally, it will print 1,1.