Java — Which interface provides capability to store objects using key-value pairs?

Difficulty: Easy

Correct Answer: java.util.Map

Explanation:

Introduction / Context:This tests knowledge of the Map interface in the Java Collections Framework.

Concept / Approach:Map defines methods to store key-value pairs, where keys are unique and values can be retrieved by keys.

Why Other Options Are Wrong:

  • Set → stores unique elements only, no key-value.
  • List → ordered collection of elements, allows duplicates.
  • Collection → root interface, but no key-value mapping.

Final Answer:java.util.Map

More Questions from Objects and Collections

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion