SCJP Module-9 Question-17


 

SCJP Module-9 Question-17

The sample code will examine your understanding about the PriorityQueque class of collection framework in Java.

The sample code will examine your understanding about the PriorityQueque class of collection framework in Java.

Given below the sample code :

1. import java.util.*;
2. public class PriorityClass {
3. public static void main(String[] args) {
4. PriorityQueue<String> pri = new PriorityQueue<String>();
5. pri.add("coke");
6. pri.add("Pepsi");
7. pri.add("Thumpsup");
8. System.out.println(pri.poll() + ":" + pri.peek());
9. }
10.}

What will be the output of the above code ?

1. Pepsi : Thumpsup
2. Thumpsup : Pepsi
3. coke : coke
4. coke : Thumpsup

Answer

(1)

Ads