0%
0 / 15 answered

while Loops() Practice Test

15 Questions
Question
1 / 15
Q1

Analyze the following code.


// Conditional loop: stop when target is found

int[] data = {2, 4, 6, 8, 10}; // sequence

int i = 0;                     // initialization

int target = 8;

while (i < data.length && data<u>i</u> != target) { // condition

    i++;                                           // update

}

System.out.println(i);

What will be the output of the given code?

Question Navigator