LearnFrenzy
Sign in Take a free test

HashMap and TreeMap · HashMap and TreeMap MCQ · Question 18

Properties of Map.of Answer, explanation & discussion

  • MCQ
  • Medium
  • 0 comments
  • Answer explained
  • Moderated community
Question 18 Back to Exercise

Which is true of Map.of("a", 1, "b", 2)?

  • A It can be modified
  • B It is immutable, rejects null keys/values and duplicate keys, and its iteration order is unspecified Correct
  • C It keeps insertion order
  • D It is a TreeMap
Correct Answer: Option B

Use new LinkedHashMap<>(…) if you need order and mutability.

Discussion & Comments 0

Share your method, a shortcut, or ask about a step you didn't follow.

No comments yet. Be the first to share your solution!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links