Skip to content
Sharp

Collections · interview question

Why do teams use an enhanced for loop over a traditional for loop in production code?

Multiple choiceEasychapter-4-curatedpremiumcollectionsiteration-and-traversal
Choose one answer
Answer and explanation

Correct answer

B. Simplified syntax

Why

The enhanced for loop provides a simplified syntax, making the code more readable and easier to maintain, especially for collections.

Test yourself on Collections

A free test with instant, explained results. No account needed.

Start free test
All Collections questions →