ExamVeda
Login
Home
This question belongs to Java Program Flow Control
Flow Control
?

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?

Answer & Solution
Correct Answer: Option C

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.

Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.