Difficulty: Easy
Correct Answer: List
Explanation:
Introduction / Context:
Different collection types capture different semantics about order and duplication, which affects query results and method contracts. Knowing these distinctions prevents subtle bugs in persistence and retrieval logic.
Given Data / Assumptions:
Concept / Approach:
A list is an ordered sequence and typically allows duplicates. A set is unordered and forbids duplicates. A bag is unordered and allows duplicates. A dictionary is keyed by unique keys rather than positional index.
Step-by-Step Solution:
Verification / Alternative check:
ODMG and many ORMs align “List” with ordered collections; indexes are stable and queries can use positional operations.
Why Other Options Are Wrong:
Set/Bag: explicitly unordered.
Dictionary: key–value store, not a plain ordered sequence.
Common Pitfalls:
Assuming set preserves insertion order; if order is required, do not model as set/bag.
Final Answer:
List
Discussion & Comments