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

Given the code fragment:

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

A.

B.

C.

D.

    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
Ankit1010

B is the correct answer

Shad657

B is correct

hashithaniro

Correct B

Vicky_65

B is the right one

iammtander

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.

arjunrawatirissoftware

Answer - B

DarGrin

B is correct

jlicini

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