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
- Which traversal method of a Binary Search Tree will always output elements in ascending order?
- The following Python code attempts to call a method from the parent class, but it's using an outdated or incorrect syntax. How should it be corrected? cla...
- Which of the following is a non-linear data structure?
- What is the average-case time complexity for search, insertion, and deletion operations in a well-designed hash table?
- The number of significant figures for 5.1250 and 0.06900 respectively are____
- cyber attack in which a malicious actor aims to render a computer or other device unavailable to its intended users by interrupting the device's normal fun...
- Consider generating all permutations of the string "ABC" using a backtracking approach. Which of the following sequences represents a valid path in the rec...
- Consider the following code: let data = [1, 2, 3]; function modifyArray(arr) { arr.push(4); arr = [5, 6]; // Reassigns local ...
- You are designing a function that takes a list of integers and returns a new list containing only the even numbers. What is a good critical thinking step b...
- What is the primary goal of analyzing an algorithm's space complexity?
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)