Exams Knowledge Hub

MCQs for Competitive Exams, School & College Exams

Module: | Arrays, Strings & Exception Handling

Q58: Consider the following statements regarding the Java Collections Framework hierarchy:

1. The java.util.Map interface extends the java.util.Collection interface to inherit standard sequential iteration methods.
2. The java.lang.Iterable interface serves as the supreme root of the Collection hierarchy, universally mandating the implementation of the iterator() method.
3. The java.util.Set interface strictly guarantees the sequential insertion order of its elements across every single one of its implementing classes.

Which of the above statements is/are correct?
A
Only 1
B
Only 2
C
Only 1 and 3
D
1, 2, and 3
✅ Correct Answer: B
🎯 Quick Answer:
The correct statement is 2 only. Statement 1 is incorrect because the Map interface is an entirely separate architectural branch that does not extend Collection. Statement 3 is incorrect because the standard Set interface does not guarantee insertion order; for example, HashSet orders elements randomly based on hash codes.
Concept Definition: The Java Collections Framework is a unified architecture providing standardized interfaces and classes to store, manipulate, and search collections of objects.
Structural Breakdown: The framework has two primary trees.
The Iterable tree (extended by Collection, which is extended by List, Set, and Queue) deals with single elements.
The Map tree deals exclusively with key-value pairs and stands entirely alone.
Historical/Related Context: In early Java (1.0 and 1.1), developers relied on legacy classes like Vector, Stack, and Hashtable, which lacked a unified interface.
Java 1.2 introduced the Collections Framework to standardize data structures, mathematically heavily inspired by the C++ Standard Template Library (STL). Causal Reasoning: Map cannot mathematically extend Collection because Collection dictates operations for single objects (e.g., add(Object o)). A Map intrinsically requires two objects (a key and a value) to function (e.g., put(Key k, Value v)), creating an irreconcilable architectural conflict that required Map to exist independently.