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
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
The main advantage of inheritance is reusability of
The main advantage of has a relationship is
reusability of code.