Skills101
← All practice quizzes

Quiz: Queue, Deque and PriorityQueue

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Learn the Queue methods that throw and the ones that do not, use ArrayDeque as both a queue and a stack, see how PriorityQueue keeps a heap inside, and solve the top-K problem asked in coding rounds.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    What does poll() return when a Queue is empty?

  2. Question 2

    What does this print?

    import java.util.*;
    public class Main {
        public static void main(String[] args) {
            Deque<Integer> s = new ArrayDeque<>();
            s.push(1); s.push(2); s.push(3);
            s.pop();
            System.out.println(s.peek());
        }
    }
    
  3. Question 3

    Why is ArrayDeque preferred over the Stack class?

  4. Question 4

    What does this print?

    import java.util.*;
    public class Main {
        public static void main(String[] args) {
            PriorityQueue<Integer> pq = new PriorityQueue<>(List.of(7, 3, 9, 1));
            pq.poll();
            System.out.println(pq.poll() + " " + pq.size());
        }
    }
    
  5. Question 5

    You print a PriorityQueue with System.out.println(pq). What do you see?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →