Menu
Topics Index
...
`

Labels


If you need explanation Read this topic

If you need Answer Take test on this topic

Labels
What will be the output of the following program?
public class Layout
{
    public static void main(String args[])
    {
        outer : for (int i = 1; i < 3; i++)
        {
            inner : for (int j = 1; j < 3; ++j)
            {
                if (j == 2)
                    continue outer;
                System.out.println("i = " + i + ", j = " + j);
            }
        }
    }
}

A. i = 1, j = 1
i = 2, j = 1
B. i = 1, j = 1
i = 1, j = 1
i = 2, j = 1
C. i = 0, j = 1
i = 1, j = 1
i = 2, j = 1
D. i = 1, j = 0
i = 1, j = 1
i = 2, j = 0
i = 2, j = 1
E. Compilation Error or Runtime Error
Topic: Java continue Statement

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Answer is A when j is 2 outer will be executed by terminating inner for loop

Posted by Sai Avinash    2014-08-12 12:41:51


A

Posted by Deepika Deepu    2014-08-12 15:29:27


a

Posted by Potti Saikrishna    2014-08-12 15:32:28


A

Posted by Vishal Kumar    2014-08-12 15:58:13


a

Posted by Zuber Rehmani    2014-08-12 17:12:31


a.continue stmt causes to go to nxt itertn widout compiling rest of stmtnt..here wen j=2 cntrl goes to outr loop  n exect

Posted by Asma Mujtaba Khan    2014-08-12 18:39:30


Congratulations Sai Avinash. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-13 04:15:15


© meritcampus 2019

All Rights Reserved.

Open In App