Difference between ‘IS-A’ and ‘HAS-A’ relationship in java?
IS-A relationship HAS- A RELATIONSHIP
Is a relationship also known as inheritance Has a relationship also known as composition or
aggregation.
For IS-A relationship we uses extends keyword For Has a relationship we use new keyword
Ex : Car is a vehicle. Ex : Car has an engine. We cannot say Car is an
engine
The main advantage of inheritance is reusability of
code
The main advantage of has a relationship is
reusability of code.