Question
Consider the following Java code snippet: import java.util.PriorityQueue; class CustomObject { int id; String name; public CustomObject(int id, String name) { this.id = id; this.name = name; } } public class HeapQuestion6 { public static void main(String[] args) { PriorityQueue pq = new PriorityQueue<>(); pq.add(new CustomObject(1, "Alice")); pq.add(new CustomObject(2, "Bob")); System.out.println(pq.poll().name); } } What will be the result of compiling and running this program?
More IT Operating System Questions
- Handshaking is :
- Consider the following code snippet (Java-like): class Animal { public void makeSound() { System.out.println("Animal makes a s...
- A counting semaphore managing a pool of 5 identical printers is initialized to 5. After 3 processes successfully acquire a printer (wait/P) and 1 process r...
- Non-Final state in DFA is represented by :
- Data warehouse has historical data
- If 2 K bits/second is bit rate, what is the minimum PCM bandwidth required for successful transmission?
- What is the worst-case time complexity for searching an element in a general (unbalanced) binary tree?
- Three processes arrive as follows: P1 (arrival=0, burst=8), P2 (arrival=1, burst=4), P3 (arrival=2, burst=2). Using Shortest Remaining Time First (SRTF, pr...
- Attributes of a file can be :
- The following C++ code has a compilation error. How can you correct it to properly use the abstract base class `Printer`? #include class Printer { ...
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)