1‘Has a ‘ relationship is also known as “composition or Aggregation”.
2As in inheritance we have ‘extends’ keyword we don’t have any keyword to
3implement ‘Has a’ relationship in java. The main advantage of ‘Has-A‘
4relationship in java code reusability. For has a relationship we use new keyword
5
6Ex: Car has an engine. We cannot say Car in an engine.
1‘is a’ relationship is also known as inheritance. We can implement
2‘is a’ relationship or inheritance in java using extends keyword.
3The advantage of inheritance or is a relationship is reusability of code
4instead of duplicating the code.
5
6Ex :
7Motor cycle is a vehicle
8Car is a vehicle
9Both, car and motorcycle extends vehicle.