nerdexam
Oracle

1Z0-851 · Question #215

Given: 34. HashMap props = new HashMap(); 35. props.put("key45", "some value"); 36. props.put("key12", "some other value"); 37. props.put("key39", "yet another value"); 38. Set s = props.keySet()…

The correct answer is B. s = new TreeSet(s). See the full explanation below for the reasoning.

Question

Given: 34. HashMap props = new HashMap(); 35. props.put("key45", "some value"); 36. props.put("key12", "some other value"); 37. props.put("key39", "yet another value"); 38. Set s = props.keySet(); 39. //insert code here What, inserted at line 39, will sort the keys in the props HashMap?

Options

  • AArrays.sort(s);
  • Bs = new TreeSet(s);
  • CCollections.sort(s);
  • Ds = new SortedSet(s);

How the community answered

(60 responses)
  • A
    13% (8)
  • B
    77% (46)
  • C
    7% (4)
  • D
    3% (2)

Community Discussion

No community discussion yet for this question.

Full 1Z0-851 Practice