1Z0-811 Control Flow and Loops Practice Question
Which TWO statements about the enhanced for loop (for-each) are correct?
⚠ Common exam trap
It's easy for candidates to think the enhanced for loop can modify elements (Option B) because they confuse the loop variable with a reference that can change the original object's state, but it only allows reading, not structural modification.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
It can iterate over any object that implements the Iterable interface.
The enhanced for loop (for-each) works with any object that implements the Iterable interface, which includes all Collection classes (like ArrayList, HashSet) and arrays. This allows the loop to iterate over elements without needing an explicit iterator or index, relying on the iterator() method provided by the Iterable contract.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
It can iterate over any object that implements the Iterable interface.
Why this is correct
This includes Collection classes.
- ✗
It can be used to modify the elements of an array.
Why it's wrong here
The loop variable is a copy; modifying it does not affect the array.
- ✗
It can only be used with collections.
Why it's wrong here
It works with arrays and Iterable objects.
- ✗
It provides an implicit counter variable.
Why it's wrong here
No counter is provided.
- ✓
It can iterate over arrays.
Why this is correct
Arrays are directly supported.
Go deeper
Related to this question
About these practice questions
Courseiva writes every 1Z0-811 question from scratch — 481 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.