IS-A and HAS-A Relationship
- IS – A Relationship :
- Inheritance = IS – A relationship
- Can access by creating an object in the extended class
- HAS – A Relationship :
- Composition = HAS – A relationship
- Can access by direct creating an object in any class
IS-A Relationship | HAS-A Relationship |
---|---|
IS-A relationship is also known as inheritance. | HAS-A relationship is also known as composition or aggregation. |
In an IS-A relationship, we use the “extends” keyword. | In HAS-A relationships, we use the “new” keyword. |