In object-oriented analysis and design (C++/UML), what does a class hierarchy primarily depict? Select the relationship a class–subclass tree is intended to model.

Difficulty: Easy

Correct Answer: It describes 'kind of' relationships.

Explanation:


Introduction / Context:
A class hierarchy is the backbone of inheritance. Understanding what it communicates conceptually is crucial for correct modeling. The question asks which real-world relationship a hierarchy intends to express.



Given Data / Assumptions:

  • Classes may form parent–child relations via inheritance.
  • Different forms of association exist: composition (has-a), usage (uses), and inheritance (is-a / kind-of).
  • We are focusing on the meaning of the inheritance diagram (a class tree).



Concept / Approach:
Inheritance models an “is-a” or “kind-of” relationship. A Dog is a kind of Animal; a Square is a kind of Shape. This is distinct from “has-a” (composition/aggregation), where an object contains or owns another object (e.g., Car has an Engine). Thus a class hierarchy primarily expresses “kind of”.



Step-by-Step Solution:
1) Identify inheritance (Base ← Derived) → semantic meaning: Derived is-a Base.2) Map to wording: “kind of” is the best natural-language equivalent of is-a.3) Recognize alternatives: “has-a” corresponds to fields/members (composition), not the hierarchy tree.4) Therefore, choose “It describes 'kind of' relationships.”



Verification / Alternative check:
UML generalization arrows encode is-a; composition/aggregation are separate notations. Documentation consistently defines hierarchies as modeling is-a.



Why Other Options Are Wrong:
Organization chart / family tree: visual analogies but not precise semantics.“Has a”: that is composition/aggregation, not inheritance.“Uses”: denotes dependency, not hierarchical generalization.



Common Pitfalls:
Overusing inheritance to model “has-a”; prefer composition for containment to reduce coupling and improve flexibility.



Final Answer:
It describes 'kind of' relationships.


More Questions from Objects and Classes

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion