← 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 →- Q1. What does poll() return when a Queue is empty?
- Q2. What does this print? (code)
- Q3. Why is ArrayDeque preferred over the Stack class?
- Q4. What does this print? (code)
- Q5. You print a PriorityQueue with System.out.println(pq). What do you see?
- Q6. How do you make a PriorityQueue that gives the LARGEST element first?
- Q7. What is the time to poll() from a PriorityQueue of n elements?
- Q8. To find the k largest of n numbers efficiently, you keep:
- Q9. What does this print? (code)
- Q10. Which statement about ArrayDeque is true?