Question

Consider the following Java code snippet:     import java.util.ArrayList;     import java.util.Arrays;     import java.util.List;     import java.util.PriorityQueue;     public class HeapQuestion10 {         public static void main(String[] args) {             List numbers = Arrays.asList(7, 2, 9, 1, 5);             PriorityQueue pq = new PriorityQueue<>(numbers); // Initialize with a collection             System.out.println(pq.poll());             System.out.println(pq.poll());             System.out.println(pq.poll());         }     }     What will be the output of this program?

A 7, 2, 9
B 1, 2, 5
C 1, 2, 7
D 2, 1, 5
E 9, 7, 5
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)