What is the is a and has a relation ship in oops concept in
java?

Answer Posted / b venkat reddy

The "is a" relationship is expressed with inheritance and
"has a" relationship expressed with composition.


Both inheritance and composition allow u to place sub-objects inside your new class.Two main techniques to code reuse are inheritance and composition.

Ex.: IS A ===>> house IS A building

class House {
.....
}
class Building extends House{
......
}

Ex.:HAS A ===>> house HAS A bathroom

class House {
Bathroom b = new Bathroom();
}

Is This Answer Correct ?    22 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the role of xml in core java?? and how we can use it?? can somebody give a sample program with explanation and from where i can read more about xml?????

1793


What are the steps involved to write rmi based programs?

559


What is the difference between a constructor and a method?

558


A person says that he compiled a java class successfully without even having a main method in it? Is it possible?

575


Can a variable be local and static at the same time?

532






explain what is transient variable in java?

610


What will happen if there is a default method conflict as mentioned above and we have specified the same signature method in the base class instead of overriding in the existing class ?

508


What is meant by method?

567


What is try-with-resources in java?

601


What is collection sort in java?

543


What is flag in java?

519


what is optional in java 8?

543


Which collection is sorted in java?

535


List down the methods and interfaces of collection class in java.

533


Tell some latest versions in JAVA related areas?

548