React.js
Angular
Ethical Hacking
Agile
AWS
BlockChain
Cassandra
Cloud
Salesforce
Scaled Agile
TOGAF
DevOps
GIT
Jenkins
Jira
Kibana
Linux
NGINX
Ansible
Artificial Intelligence
in JAVA by
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.
Click here to read more about JAVA

1 Answer

0 votes
by

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.

Related questions

Madanswer
...