Question

Consider the following Java code snippet:     import java.util.Collections;     import java.util.PriorityQueue;     public class HeapQuestion2 {         public static void main(String[] args) {             PriorityQueue maxHeap = new PriorityQueue(Collections.reverseOrder());             maxHeap.add(10);             maxHeap.add(5);             maxHeap.add(20);             maxHeap.add(3);             System.out.println(maxHeap.poll());             System.out.println(maxHeap.poll());         }     }     What will be the output of this program?

A 3, 5
B 20, 10
C 10, 5
D 20, 3
E 5, 10
Practice Next

Hey! Ask a query