LearnFrenzy
Sign in Take a free test

HashMap and TreeMap · HashMap and TreeMap MCQ · Question 9

null keys in TreeMap Answer, explanation & discussion

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

What happens when you put a null key into a TreeMap that uses natural ordering?

  • A It is stored first
  • B NullPointerException Correct
  • C It is ignored
  • D It is stored last
Correct Answer: Option B

The key must be compared with compareTo.

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