Share on Google+Share on Google+

SCJP Module-9 Question-13

The Sample code given below will test your knowledge of HashMap of Collection framework in Java.

Given below the sample code :

4. HashMap hm = new HashMap();
5. hm.put("key45", "some value");
6. hm.put("key12", "some other value");
7. hm.put("key39", "yet another value");
8. Set a = hm.keySet();
9. // insert code here

What code should be at line 9 to sort the keys in HashMap "hm"?

1. a = new SortedSet(a) ;

2. Collections.sort(a);

3. a = new TreeSet(a);

4. a = Collections.sort(a);




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