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 cryptography, a trapdoor function is defined as:
- Which SQL query correctly displays all records from EMPLOYEE_CARD where Company is Reliance, Infosys, TCS, or Cognizant?
- In a multi-homed network, BGP route flapping causes external instability. Which mechanism MOST effectively prevents repeated advertisement of unstable rout...
- In a recursive subset_sum function, backtrack(index, current_subset, current_sum), to explore the option of *including* the current element arr[index], whi...
- What is the output of the following Java code? public class Test { public static void main(String[] args) { String s1 = "Java"...
- Consider the following code: let data = [1, 2, 3]; function modifyArray(arr) { arr.push(4); arr = [5, 6]; // Reassigns local ...
- A max-heap is built from the array [3, 9, 2, 1, 4, 5] using standard bottom-up heapify. What is the resulting array?
- Which of the following is an example of parametric polymorphism?
- Which refers to the creation of Internet Protocol (IP) packets with a false source IP address to impersonate another computer system.
- R has FDs A→B, B→C and C→D. Which closure contains all attributes?
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)