Question

Consider the following Java code snippet:     import java.util.PriorityQueue;     public class HeapQuestion8 {         public static void main(String[] args) {             PriorityQueue pq = new PriorityQueue();             pq.add(5);             pq.add(1);             pq.add(5); // Adding a duplicate             pq.add(3);             System.out.println(pq.poll());             System.out.println(pq.poll());             System.out.println(pq.poll());         }     }     What will be the output of this program?

A 1, 3, 5
B 1, 5, 5
C 3, 5, 5
D 1, 5, 3
E 5, 5, 3
Practice Next

Hey! Ask a query