Home Tutorial Java Scjp Part9 SCJP Module-9 Question-17

 
 

SCJP Module-9 Question-17
Posted on: July 17, 2010 at 12:00 AM
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)

Related Tags for SCJP Module-9 Question-17:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.