Question
Consider the following Java code snippet: import java.util.PriorityQueue; import java.util.Comparator; class Item { int priority; String name; public Item(int priority, String name) { this.priority = priority; this.name = name; } @Override public String toString() { return name + "(" + priority + ")"; } } public class HeapQuestion7 { public static void main(String[] args) { // Create a min-heap based on 'priority' PriorityQueue pq = new PriorityQueue<>(Comparator.comparingInt(item -> item.priority)); pq.add(new Item(5, "Task A")); pq.add(new Item(1, "Task B")); pq.add(new Item(10, "Task C")); pq.add(new Item(3, "Task D")); System.out.println(pq.poll().name); System.out.println(pq.poll().name); } } What will be the output of this program?
More IT Operating System Questions
- In C the array index starts from :
- Given the array [38, 27, 43, 3, 9, 82, 10], what would be the two sorted subarrays immediately *before the final merge step* in a Merge Sort algorithm?
- The error in Simpson's 1/3 Rule is proportional to:
- Which device operates at the Data Link Layer and uses MAC addresses to forward frames only to the intended recipient port?
- Which of the following statements about a B+ Tree is correct?
- Which register stores the temporary results during computation?
- Router is responsible for packet forwarding, including routing. Router works at which layer?
- In a bank's IT governance framework, which statement correctly describes the relationship between a Business Continuity Plan (BCP) and a Disaster Recovery ...
- In dynamic memory partitioning, the 'Best-Fit' allocation algorithm satisfies a memory request by selecting:
- In a 0/1 Knapsack problem implemented using dynamic programming, a common mistake is to allow items to be reused, effectively turning it into an unbounded ...
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
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)