Skip to content
Sharp

Collections · interview question

You have a List of products and need to remove all items with a price below a certain threshold. Which iteration method is most efficient?

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

Correct answer

D. For-each loop with removeIf()

Why

Using removeIf() with a lambda expression efficiently removes items matching a condition without explicit iteration code.

Test yourself on Collections

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

Start free test
All Collections questions →