← Quiz: Queue, Deque and PriorityQueue: all 10 questions
Quiz: Queue, Deque and PriorityQueue · Question 1 of 10
What does poll() return when a Queue is empty?
What does poll() return when a Queue is empty?
- A.It throws NoSuchElementException
- B.null
- C.0
- D.It waits until an element arrives
Answer & explanation
Correct answer: null
poll and peek return null for an empty queue; remove and element throw instead.
Can you get the rest right without peeking?
Take the timed Quiz: Queue, Deque and PriorityQueue quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →