3.1 Object Hierarchy and Generalization

Cards (6)

  • Object hierarchy is a way of organizing objects into families based on their shared characteristics or attributes. This helps in  creating a better understanding of the relationships between  different objects and their behavior.
  • Since objects are organized in hierarchy, objects clustered in a  category serves as the specifications of that category while the  category itself is the generalization of those objects
  • Generalization/specification is hierarchic in nature
  • This ‘is a’ relationship (subclass is a superclass) instilled on  classes/objects is another basic concept of object-oriented  paradigm called inheritance
  • Inheritance is one of the fundamental concepts in object-oriented programming that allows us to define a new class  based on an existing class. The existing class is called the  superclass, while the new class is called the subclass
  • By inheriting from a superclass, the subclass automatically  inherits all the attributes and methods of the superclass. This allows us to reuse code and avoid duplicating code across  multiple classes, leading to more efficient and maintainable  implementation