Menu
Topics Index
...
`

dowhile and Continue statement


If you need explanation Read this topic

If you need Answer Take test on this topic

dowhile and Continue statement
What will be the output of the following program?
public class DemoOnContinue {
    public static void main(String args[]) {
        int first = 5, second = 20;
        do {
            if (first++ > --second) {
                continue;
            }
          } while (first < 15);
        System.out.println("first = " + first + " and second = " + second);
    }
}

A. first = 15 and second = 15
B. first = 10 and second = 15
C. first = 15 and second = 10
D. Compilation Error
E. 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.

C is ans..v r incrmntg 10 tyms first from 5 untill its less to 15 so first is 15 and second decrmntd 10 tyms ie from 20 to 10

Posted by Shabaaz Shaikz    2014-07-31 12:47:49


ans is C..afrt cmng out of loop first is=15 second is 10

Posted by Uday Kumar    2014-07-31 12:48:10


Answer is C as first will be grater than second upon increments on first and decrements on second upto first =15 and second=10 only

Posted by Sai Avinash    2014-07-31 12:51:22


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

Posted by Merit Campus    2014-08-01 05:15:32


© meritcampus 2019

All Rights Reserved.

Open In App