Lec 08
Lec 08
Programming
Topics to be covered today
Inheritance (IS-A relationship)
Aggregation (HAS-A relationship)
Inheritance
One of the pillars of OPPs(Object Oriented
programming system).
a mechanism in which one object acquires all the
Subclass
Save as Programmer.java
Example 2
InnerView
when an object to My_Calculation class is
created, a copy of the contents of the superclass
is made within it. That is why, using the object of
the subclass you can access the members of a
superclass
Superclass reference variable
The Superclass reference variable can hold the
subclass object but using that variable you can
access only the members of the superclass
So, it is recommended to always create reference
inherited by subclasses
Aggregation
Save as Address.java
Employee Class (Emp.java)
Task
Question:
In inheritance, a subclass inherits all the members
both types.
Questions?