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

I want to persist data of objects for later use. What is the best approach to do so?

598


What are the different types of inner classes?

536


Can we call the run() method instead of start()?

595


Explain the use of javap tool.

636


What is meant by data hiding in java?

640






What are class types in java?

582


What is a finally block? Is there a case when finally will not execute?

553


What is int argc char * argv?

569


Is it necessary that each try block must be followed by a catch block?

562


What is encapsulation in java?

629


How many days will it take to learn java?

519


What is the function of java?

517


What does \ mean in regex?

626


How do you define a set in java?

518


What are the 4 types of research methods?

515