πŸ“Š JAVA
Q. What will be the output of the following code –
Code:
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.PriorityQueue;

public class MyClass
{
public static void main(String args[])
{
PriorityQueue<Integer> q = new PriorityQueue<Integer>();
q.add(1);
q.add(2);
q.add(3);
System.out.println(q.poll());
System.out.println(q.offer(4));
q.add(1);
q.remove(2);
System.out.println(q.peek());
System.out.println(q);
}
}
  • (A) 1 true 1 [1, 3, 4]
  • (B) 3 true 1 [1, 3, 4]
  • (C) 3 false 1 [1, 3, 4]
  • (D) 1 false 1 [1, 2, 4]
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1 true 1 [1, 3, 4]

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
211
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Uday Singh
Publisher
πŸ“ˆ
99%
Success Rate