Skip to content
Sharp

Core Java · interview question

Given a list of product names, which collection would help you efficiently find out how many times each product appears?

Multiple choiceMediumchapter-4-curatedpremiumcore-javacode-reading-with-collections
Choose one answer
Answer and explanation

Correct answer

A. HashMap

Why

HashMap can be used to map product names (keys) to their counts (values), allowing efficient tracking of the frequency of each product.

Test yourself on Core Java

A free test with instant, explained results. No account needed.

Start free test
All Core Java questions →