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

Given:

What is the result?

    Correct Answer: C

    The code initializes x to 0 and y to 6, and it evaluates the condition in the for loop where it increments x and decrements y each iteration. The loop continues as long as x is less than y. Inside the loop, there is a condition that checks if x is even using x%2==0, and if it is, it uses continue to skip the rest of the loop iteration. Therefore, the loop will skip printing any values when x is even. When x is 1 and y is 5, the condition x%2==0 is false, so it prints 1-5. The next possible time it would print is when x is 3 and y is 3, but x is no longer less than y, so the loop ends. Hence, the only output is 1-5.

Discussion
gopu_azure32

I followed examtopics and I FAILED

d7bb0b2Option: C

1-5 is the correct, print only when x is a impar number => result can be 1-5 and 3-3 but 3-3 so no match with the for condition (x<y) so breack loop and print only 1-5

james2033Option: C

public class Tester { public static void main(String[] args) { int x = 0, y = 6; for (; x < y; x++, y--) { if (x % 2 == 0) { continue; } System.out.println(x + "-" + y); } } } Result: 1-5 , choose C.

qulytOption: C

x = 0 y = 6 1st iteration 0 < 6 true 0%2 = 0 == 0? true continue to 2nd iteration 2nd iteration 1 < 5 true 1%2 = 1 == 0 ? false print 1 - 5 x = 2 y = 4 3rd iteration 2 < 4 true 2%2 = 0 ==0? true continue to 4th iteration 4th iteration 3 < 3 false end.

StavokOption: C

c is correct

JGR_77Option: B

b is correct: ublic class Principal { public static void main(String[] args) { int x = 0, y = 6; for (; x < y; x++, y--) { System.out.println(x + "-" + y); } } } 0-6 1-5 2-4

JGR_77

C-Correct

d7bb0b2

Bad answered, delete the if code block

kavithaprasanthOption: C

C-Correct

Guru_01Option: C

C is correct

Ankit1010Option: C

C - Correct Answer

UcefSoftOption: C

C is correct