Skip to content
Sharp

Collections · interview question

Given a Deque, what is the result of calling addFirst() followed by pollLast()?

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

Correct answer

A. The element is inserted at the front and removed from the back.

Why

addFirst() inserts an element at the front of the Deque, and pollLast() removes an element from the back, thus the element is inserted at the front and removed from the back.

Test yourself on Collections

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

Start free test
All Collections questions →