Oracle Java SE 8 Programmer II 1z0-809 Question # 17 Topic 2 Discussion

Oracle Java SE 8 Programmer II 1z0-809 Question # 17 Topic 2 Discussion

1z0-809 Exam Topic 2 Question 17 Discussion:
Question #: 17
Topic #: 2

Given the code fragment:

public class Foo {

public static void main (String [ ] args) {

Map unsortMap = new HashMap< > ( );

unsortMap.put (10, “z”);

unsortMap.put (5, “b”);

unsortMap.put (1, “d”);

unsortMap.put (7, “e”);

unsortMap.put (50, “j”);

Map treeMap = new TreeMap (new

Comparator ( ) {

@Override public int compare (Integer o1, Integer o2) {return o2.compareTo

(o2); } } );

treeMap.putAll (unsortMap);

for (Map.Entry entry : treeMap.entrySet () ) {

System.out.print (entry.getValue () + “ “);

}

}

}

What is the result?


A.

A compilation error occurs.


B.

d b e z j


C.

j z e b d


D.

z b d e j


Get Premium 1z0-809 Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.