A

Admin • 828.03K Points
Coach

Q. What is the output of `map.put(1, null)` if 1 already exists with a non-null value?

  • (A) The value is not updated
  • (B) The key is removed
  • (C) The value is replaced with null
  • (D) Throws NullPointerException
  • Correct Answer - Option(C)
  • Views: 9
  • Filed under category Java
  • Hashtags: Java Map

Explanation by: Admin
`put()` replaces the existing value even with null.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.