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
- Consider three processes P1, P2, P3 with burst times 10, 5, 8 milliseconds respectively. All arrive at time 0. If they are scheduled using the Shortest Job...
- Fill in the correct option for 28 blank space.
- Question 3
- Which of the following statements about Referential Integrity is correct?
- What is the primary purpose of the UNION ALL operator in SQL?
- What is the primary purpose of a system call?
- What is the primary goal of disk scheduling in operating systems?
- Consider the following JSON object: json { "user": { "id": "u123", "name": "Alice", "age": 30, "address": { "street": "123 ...
- State true or false MD5 Hashing Algorithm was invented by RSA Labs (Ronald Rivest) in 1991. MD5 was invented to replace its previous version, MD4. When Da...
- You are using Python's built-in dict to store custom objects. class MyObject: def __init__(self, value): self.value = value # Missi...
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)