Junior
What is the inheritance order of the following classes: List, Set, Collection, and Map?
sobes.tech AI
Answer from AI
In Java, the Collection interface is the base for most collections. The inheritance hierarchy is as follows:
- Collection — the basic interface for groups of objects.
- List and Set — both extend Collection.
- Map does not inherit from Collection; it is a separate interface for key-value mappings.
The hierarchy looks like this:
Collection
├── List
└── Set
Map (separate interface)
Thus, List and Set are subtypes of Collection, while Map is a separate data structure with its own interface.