Class3
Class3
In a class hierarchy - we call the derived class as sub-class and parent class is
called super class
Types of Inheritance -
a. Single inheritance - Only one derived class from a base class is called single
inheritance
b. Multilevel inheritance - More than one class getting derived in a herirachy, one
after the other is called multilevel inheritance
c. Heirarchical inheritance - More than one class is derived from a single parent
class
d. Multiple inheritance - is not through classes but through interfaces. A derived
class inherits from more than one parent class
e. Hybrid inheritance - also called diamond inheritance where two interfaces derive
from parent class and another child class derives from thees two interfaces
Inheritance represents the IS-A relationship which is also known as the parent-
child relationship.
It’s a form of association with weaker relationship strength, whereby the lifetime
of the contained object (part) is not controlled based on the lifetime of the
container object (whole).
The lifetime of contained object (part) is NOT DEPENDENT on the container object
(whole)
Example - Department contains the student object.
Aggregation is a type of association that represents a relationship where one class
is a collection or container of another class. It depicts a “has-a” relationship,
where the container object can exist independently of its contents, and the
contained objects can exist independently of the container.