LearnFrenzy
Sign in Take a free test

HashMap and TreeMap · HashMap and TreeMap MCQ · Question 13

What map.merge does Answer, explanation & discussion

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

What does counts.merge(word, 1, Integer::sum) do?

  • A Always sets the count to 1
  • B Inserts 1 if the word is absent, otherwise adds 1 to the existing count Correct
  • C Merges two maps
  • D Removes the word
Correct Answer: Option B

The idiomatic way to count.

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