Skip to content
Sharp

Collections · interview question

Which approach is explicitly designed for safe removal while traversing a collection?

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

Correct answer

D. Use an Iterator and remove through the iterator

Why

When traversal and removal need to happen together, the iterator API exists for exactly that reason. Good collection code chooses the traversal tool that matches the operation being performed.

Test yourself on Collections

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

Start free test
All Collections questions →