Given this array:
Which two code fragments, independently, print each element in this array? (Choose two.)
A.
B.
C.
D.
E.
F.
Given this array:
Which two code fragments, independently, print each element in this array? (Choose two.)
A.
B.
C.
D.
E.
F.
The correct answers are B and E. Option B uses the enhanced for loop (also called for-each loop) which iterates over each element in the array and directly prints the value of the element. Option E uses a traditional for loop that iterates from index 0 to the length of the array and prints each element by accessing the array with the index. Option A is incorrect because it tries to use the enhanced for loop with array indexing, which is not valid. Option C is incorrect because the for loop is in an incorrect format and will result in an error. Option D is incorrect because it prints the index instead of the element. Option F is incorrect because the for loop lacks an initialization part for the variable i.
Answer B and E.
It's A, E
B, E are correct
B and E are correct
B and E is correct
Answer is BC
B and E is correct.