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

 
 

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

Answer

(3)

Related Tags for SCJP Module-9 Question-13:


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.