🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.It throws NoSuchElementException
  2. B.null
  3. C.0
  4. 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 →