🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Queue, Deque and PriorityQueue: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. What does poll() return when a Queue is empty?
  2. Q2. What does this print? (code)
  3. Q3. Why is ArrayDeque preferred over the Stack class?
  4. Q4. What does this print? (code)
  5. Q5. You print a PriorityQueue with System.out.println(pq). What do you see?
  6. Q6. How do you make a PriorityQueue that gives the LARGEST element first?
  7. Q7. What is the time to poll() from a PriorityQueue of n elements?
  8. Q8. To find the k largest of n numbers efficiently, you keep:
  9. Q9. What does this print? (code)
  10. Q10. Which statement about ArrayDeque is true?