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
- What is the recurrence relation for Merge Sort?
- Which of the following statements about guided transmission media is correct?
- OLAP and OLTP differs in
- *-adc is which form of representation ?
- Which of the following properties is true for a binary heap?
- A Repeater operates at which layer of the OSI model?
- Which operator in C has the highest precedence among the following?
- Which of the following operation is performed by Domain Name Server (DNS)?
- Which of the following best describes the nature of TCP (Transmission Control Protocol) as a connection-oriented protocol?
- The Knuth-Morris-Pratt (KMP) algorithm improves upon the Naive approach by avoiding unnecessary re-comparisons. It achieves this by:
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)