Java OCA OCP Practice Question 1062

Question

Which of the following can loop through an array without referring to the elements by index?

  • A. do-while loop
  • B. for (traditional)
  • C. for-each
  • D. while


C.

Note

While a traditional for loop often loops through an array, it uses an index to do so, making Option B incorrect.

The for-each loop goes through each element, storing it in a variable.

Option C is correct.




PreviousNext

Related