Share on Google+Share on Google+

SCJP Module-9 Question-17

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. }

What will be the output of the above code ?

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




Posted on: July 17, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.


Advertisement null