Get ready for your Object‑Oriented Programming Test. Use flashcards and multiple-choice questions. Each question includes hints and explanations. Prepare for your exam today!

Multiple Choice

Which collection is used to map keys to values, ensuring key uniqueness?

This question hinges on mapping keys to values with unique keys. A Map is designed to store pairs where each key identifies a value, and no two entries share the same key, which makes lookups by key fast and unambiguous. A List is just an ordered collection that can include duplicates and has no direct key-to-value relation. A Set ensures unique elements but doesn’t map keys to values. A Queue focuses on processing order (FIFO) and also doesn’t provide key-value associations. So, a Map best fits the requirement of mapping keys to values with key uniqueness.

This question hinges on mapping keys to values with unique keys. A Map is designed to store pairs where each key identifies a value, and no two entries share the same key, which makes lookups by key fast and unambiguous. A List is just an ordered collection that can include duplicates and has no direct key-to-value relation. A Set ensures unique elements but doesn’t map keys to values. A Queue focuses on processing order (FIFO) and also doesn’t provide key-value associations. So, a Map best fits the requirement of mapping keys to values with key uniqueness.