Examveda
Examveda

public class Test{
      public static void main(String [] args){
            int x = 0;
            // insert code here
            do{ } while(x++ < y);
            System.out.println(x);
      }
}

Which option, inserted at line 4, produces the output 12?

A. int y = x;

B. int y = 10;

C. int y = 11;

D. int y = 12;

E. None of the above will allow compilation to succeed.

Answer: Option C

Solution(By Examveda Team)

x reaches the value of 11, at which point the while test fails.
x is then incremented (after the comparison test!), and the println() method runs.
Hence, choice A, B, D, E, and F are incorrect based on the above point.


This Question Belongs to Java Program >> Flow Control

Join The Discussion

Related Questions on Flow Control