11 November 2011

Composition vs Inheritance in OOPS


 Composition vs Inheritance in OOPS

Composition – Composition is used when the two class has-a relationship among classes
Inheritance – Inheritance is used when the derived class is-a relationship base class

For example :
Take two class
1.House owner
2.House

House owner is a House is not valid - Inheritance
House owner has a house is valid - Composition

For example :
Take two class
1.Game
2.Cricket


Cricket is a game is valid - Inheritance
Cricket has a game is invalid - Composition

3 comments:

  1. "Great blog created by you. I read your blog, its best and useful information. You have done a great work. Super blogging and keep it up.php jobs in hyderabad.
    "

    ReplyDelete
  2. • I very much enjoyed this article. Nice article thanks for given this information. I hope it useful to many Peopledata since Online Training india

    ReplyDelete
  3. • Nice and good article. It is very useful for me to learn and understand easily. Thanks for sharing your valuable information and time. Please keep updatingAzure Online Training Hyderabad

    ReplyDelete

Comments Welcome