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

Given the code fragment:

Which "for" loop produces the same output?

    Correct Answer: B

    The given while loop initializes x to 0 and prints x while incrementing it until x is less than 10. This means it prints the numbers 0 to 9. Option B is the only answer that initializes the variable, checks the condition before each iteration, and increments the variable after printing, resulting in the same output: 0 to 9.

Discussion
d7bb0b2Option: B

b is correct A-> not compile miss declaration B-> print 0-9 => ok C-> print 0-10=> not valid D-> print 1 10=> not valid

ASPushkin

C) is not compiled

ASPushkin

c) it will compile

ASPushkinOption: B

answer : B A) not compiled initialization part should be missed or be a valid java statement B) correct >0123456789 C) not compiled (there is no conditional part) D) not right ++ operator as prefix returns us : >12345678910

d7bb0b2

C compile, in for nothing clause is required, the bad thing with this is that print 10, so requiered es print 0,9