Question discussion

What will be the output of the following Java code?

359030Medium DSSSB TGT Computer Science 0 replies 0 views
0
What will be the output of the following Java code?
public class DoWhileExample {
    public static void main(String[] args) {
        int x = 10;
        do {
            System.out.println("x = " + x);
            x++;
        } while (x < 13);
    }
}
  • Ax = 10 x = 11 x = 12
  • Bx = 10
  • Cx = 10 x = 11
  • DNo output
Correct answer: A

Explanation

x starts at 10 and the do-while prints x = 10, 11 and 12; when x becomes 13 the condition x < 13 fails.

Discussion 0

Nobody has replied yet. Start the discussion!