Which collection type is ordered and allows duplicates?

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 type is ordered and allows duplicates?

Explanation:
A list is the collection that is ordered and allows duplicates. The order means elements have a defined sequence, so you can access them by position and the sequence is preserved as you add them. Duplicate values are allowed, so you can have repeated elements in the same collection, like [1, 2, 2, 3]. Sets enforce uniqueness, so duplicates aren’t allowed, and maps store key-value pairs where keys are unique and iteration focuses on those pairs rather than a simple ordered list of elements. An iterable is just something you can traverse, but it doesn’t specify a particular storage behavior regarding order or duplicates. So the combination of preserving order and permitting duplicates is uniquely provided by a list.

A list is the collection that is ordered and allows duplicates. The order means elements have a defined sequence, so you can access them by position and the sequence is preserved as you add them. Duplicate values are allowed, so you can have repeated elements in the same collection, like [1, 2, 2, 3]. Sets enforce uniqueness, so duplicates aren’t allowed, and maps store key-value pairs where keys are unique and iteration focuses on those pairs rather than a simple ordered list of elements. An iterable is just something you can traverse, but it doesn’t specify a particular storage behavior regarding order or duplicates. So the combination of preserving order and permitting duplicates is uniquely provided by a list.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy