nerdexam
Oracle

1Z0-809 · Question #277

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…

The correct answer is B. d b e z j. You've hit your session limit · resets 5:20pm (America/New_York)

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

How the community answered

(28 responses)
  • A
    14% (4)
  • B
    75% (21)
  • C
    4% (1)
  • D
    7% (2)

Explanation

You've hit your session limit · resets 5:20pm (America/New_York)

Community Discussion

No community discussion yet for this question.

Full 1Z0-809 Practice