1z0-808 Exam QuestionsBrowse all questions from this exam

1z0-808 Exam - Question 14


Given the code fragment:

Which option can replace xxx to enable the code to print 135?

A.

B.

C.

D.

Show Answer
Correct Answer:

Option B is the correct answer: `int e = 0; e < 5; e += 2`. This loop initialization and condition cause the loop to iterate over the array with an increment of 2, selecting elements at indices 0, 2, and 4. The corresponding elements in the array `a[]` are 1, 3, and 5, which will be printed sequentially, resulting in the output '135'.

Discussion

8 comments
Sign in to comment
Ankit1010
Feb 7, 2023

B is the correct answer

hashithaniro
Dec 17, 2022

Correct B

Shad657
Feb 12, 2023

B is correct

Vicky_65
Apr 1, 2023

B is the right one

jlicini
Aug 3, 2023

int a [] = {1,2,3,4,5}; for (int e=0; e<5; e+=2){ System.out.print(a[e]); }

DarGrin
Sep 29, 2023

B is correct

arjunrawatirissoftware
Oct 11, 2023

Answer - B

iammtander
Jul 12, 2024

A STEP BY STEP ANSWER EXPLAINED - The correct answer is B: int e = 0; e < 5; e += 2 : WHY? - This option initializes e to 0, continues the loop while e is less than 5, and increments e by 2 each iteration. - This results in accessing array elements at indices 0, 2, and 4, which correspond to the values 1, 3, and 5. - Therefore, option B will enable the code to print 135.