Skip to content
Sharp

Collections · interview question

What happens if you call remove() on an empty Queue?

Multiple choiceEasychapter-4-curatedpremiumcollectionsqueue-and-deque-basics
Choose one answer
Answer and explanation

Correct answer

D. Throws NoSuchElementException

Why

Calling remove() on an empty Queue throws a NoSuchElementException, as it attempts to remove an element that does not exist.

Test yourself on Collections

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

Start free test
All Collections questions →