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
- An IPv4 packet has 3000-byte total length and must cross an MTU of 1000 bytes. With a 20-byte header, how many fragments are needed?
- What is the main purpose of disk scheduling in an operating system?
- A page has 2^12-byte size and a logical address is 32 bits. How many bits identify the page number?
- Which of the following conditions is essential for applying dynamic programming to a problem?
- Which type of cable is referred to as K-type or Category 5e/6 in network infrastructure, and what is its maximum standard data transfer rate for Category ...
- There is a BST and below is the Pre order of the BST, What will be it’s In order 150 70 60 80 250 200 350
- Frame relay :
- Which type of relationship does inheritance represent?
- Binary Search is an efficient searching algorithm that follows the Divide and Conquer approach. What is its time complexity?
- The following C++ code has a common inheritance-related issue. How can it be debugged to ensure the derived class constructor properly initializes the base...
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)