Multiple Choice Question

Quiz Guidelines

 

QID: 
343
Question: 

In the following code what will be the output if 0 (integer value zero) is passed to loopTest()?

public class TestClass{
public void loopTest(int x){
loop: for (int i = 1; i < 5; i++){
for (int j = 1; j < 5; j++){
System.out.println(i);
if (x == 0) { continue loop; }
System.out.println(j);
}
}
}
}

Select 1 option

A. The program will not compile.
B. It will print 1 2 3 4
C. It will print 1 1 2 3 4
D. It will print 1 1 2 2 3 3 4 4
E. Produces no output

Q&A Set: