Exam 1z0-829 All QuestionsBrowse all questions from this exam
Question 20

Given:

What is the result?

    Correct Answer: A

    First, the variable x is initialized to 2, and y is set to x. The program enters a while loop that runs while y is less than 3. Inside the loop, there is a switch statement on the value of y. For y=2, the switch case 0+x is executed, which is case 2. The value of y is incremented (y++) to become 3. Because there is no break statement, the next case (case 1) is also executed, incrementing y again to 4. Now y is no longer less than 3, so the loop terminates. The final value of y, which is 4, is printed.

Discussion
xplorerpjOption: A

Tested & the code will print 4. Reason is that, both the cases (0+x and 1) will get executed since there's no break statement.

zuluitaiOption: A

the code will print 4