Menu
Question Index
...

What will be the output of the following program?

import java.util.*;

   public class Book {
    public static void main(String[] args) {
        PriorityQueue<String> bk = new PriorityQueue<String>();
        bk.add("paper");
        bk.add("pen");
        bk.add("pencil");
        System.out.println(bk.poll() + "," + bk.peek());
    }
}


paper,pen
pencil,paper
paper,paper
pencil,pencil
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java PriorityQueue - PriorityQueue In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App