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

Given:

What is the result?

    Correct Answer: D

    The given code is a loop structure with a do-while loop containing a for loop inside it. The variable 'i' is initially set to 10. In each iteration of the do-while loop, 'i' is divided by 2, and the resulting value is assigned to 'j'. The for loop prints 'j' until 'j' is greater than 0, decrementing 'j' with each iteration. After the for loop completes, 'i' is decremented by 2. This process continues until 'i' is no longer greater than 0. The sequence of prints will be: 5 4 3 2 1 (when i=10), 4 3 2 1 (when i=8), 3 2 1 (when i=6), 2 1 (when i=4), 1 (when i=2). Hence, the output will be '5 4 3 2 1 4 3 2 1 3 2 1 2 1 1'.

Discussion
james2033Option: D

public class Question2 { public static void main(String[] args) { int i = 10; do { for (int j = i / 2; j > 0; j--) { System.out.print(j + " "); } i -= 2; } while (i > 0); } } Resutl: 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 . --> Choose D.

d7bb0b2Option: D

D is correct

kvarpeOption: A

Correct Ans is A

curioussOption: D

✅ D https://onecompiler.com/java/3zkx2jqfm

curioussOption: D

✅ D https://onecompiler.com/java/3zkx2jqfm

qulytOption: D

Look for all prints below: i = 10 j = 5 print 5 4 3 2 1 i = 8 j = 4 print 4 3 2 1 i = 6 j = 3 print 3 2 1 i = 4 j = 2 print 2 1 i = 2 j = 1 print 1

LebanninOption: D

D is the correct answer

muzireOption: D

D is the answer

MtandwaOption: D

Answer is D

StavokOption: D

D is the correct answer

tyfahOption: D

D is the correct answer

bharathdaveOption: D

D is correct

Arvind_Kumar_AvinashOption: D

Correct answer: D

kavithaprasanthOption: D

D is correct

AnotherJavaGuyOption: D

D is Correct

Guru_01Option: D

D is correct

Ankit1010Option: D

D is correct