Oracle
1Z0-809 · Question #277
1Z0-809 Question #277: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-809 to reveal the answer and full explanation for question #277. The question stem and answer options stay visible for context.
Question
QUESTION 302
Given the code fragment:
public class Foo {
public static void main (String [ ] args) {
Map<Integer, String> unsortMap = new HashMap< > ( );
unsortMap.put (10, "z");
unsortMap.put (5, "b");
unsortMap.put (1, "a");
unsortMap.put (7, "e");
unsortMap.put (50, "j");
Map<Integer, String> treeMap = new TreeMap <Integer, String> (new Comparator<Integer> () {
@Override
public int compare (Integer o1, Integer o2) {return o1.compareTo(o2); }
});
treeMap.putAll (unsortMap);
for (Map.Entry<Integer, String> entry : treeMap.entrySet ()) {
System.out.print (entry.getValue () + " ");
}
}
}
What is the result?
Options
- AA compilation error occurs.
- Bd b e z j
- Cz b e d
- Dz b d e j
Unlock 1Z0-809 to see the answer
You've previewed enough free 1Z0-809 questions. Unlock 1Z0-809 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.