Difference between ‘IS-A’ and ‘HAS-A’ relationship in java?

IS-A RELATIONSHIPHAS- A RELATIONSHIP
Is a relationship also known as inheritanceHas a relationship also known as composition or aggregation.
For IS-A relationship we uses extends keywordFor 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 codeThe main advantage of has a relationship is reusability of code
IS-A VS HAS-A

Posted

in

Tags:

Comments

Leave a Reply