Flow Control

Q1: What will be the output of the program?
int i = 0, j = 5; 
tp: for (;;) 
    {
        i++;  
        for (;;) 
        {
            if(i > --j) 
            {
                break tp; 
            } 
        } 
        System.out.println('i =' + i + ', j = ' + j);

A i = 1, j = 0

B i = 1, j = 4

C i = 3, j = 4

D Compilation fails.

ANS:A - i = 1, j = 0

If you examine the code carefully you will notice a missing curly bracket at the end of the code, this would cause the code to fail.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.