🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Classes, Modules, Map and Set: all 10 questions

Quiz: Classes, Modules, Map and Set · Question 9 of 10

When is a Map a better choice than a plain object?

When is a Map a better choice than a plain object?

  1. A.When you need to send the data as JSON
  2. B.When keys can be any type and you add and remove entries often
  3. C.When there are exactly two fixed keys
  4. D.Never; Map is deprecated
Answer & explanation

Correct answer: When keys can be any type and you add and remove entries often

Map accepts any key type, keeps insertion order and has a size property.

Can you get the rest right without peeking?

Take the timed Quiz: Classes, Modules, Map and Set quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →