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

 
 

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

Advertisement

Related Tags for SCJP Module-9 Question-17:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 17, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com