Java Programming - Objects and Collections - Discussion


Which interface provides the capability to store objects using a key-value pair?

[A]. Java.util.Map
[B]. Java.util.Set
[C]. Java.util.List
[D]. Java.util.Collection

Answer: Option A


An object that maps keys to values. A map cannot contain duplicate keys; each key can map to at most one value.

Shubham said: (Nov 17, 2011)  
Why the Java.util.Map class can not create duplicate key?

Pawan said: (Apr 1, 2013)  
What is key value pair?

Kumar said: (Jul 21, 2016)  
A key value pair is used to the collection in Map interface where the key represents index and value represent the object at specific index value.


Nikhil said: (Jul 12, 2021)  
We can do this with any type of Collection, so why only Map? Please explain in detail.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.