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

🎓
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
  • 200 Questions with Detailed Solutions
  • Section-wise Coverage (GA, English, Quant & Reasoning)