Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 are the data types supported by java?

1028


What is role of void keyword in declaring functions?

1052


Can extern variables be initialized?

954


How do you know if a value is nan?

1059


Explain about fail fast iterators in java?

1063


What is the instance of an object?

1196


Which are the two subclasses under exception class?

1095


How to run a JAR file through command prompt?

1281


What is the use of parse function in java?

986


What are the changes in java.io in java 8 ?

1036


Can we have two main methods in a java class?

1059


What is data type in java?

908


Explain access modifiers in java.

1046


What do you mean by inner class in java?

1086


How many digits can a float hold?

1013