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

Java Programming Objects and Collections Difficulty: Easy
Choose an option
  • A
    java.util.Map
  • B
    java.util.Set
  • C
    java.util.List
  • D
    java.util.Collection

Answer

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

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