Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Composition vs Inheritance...

 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the difference between Composition vs Inheritance....thanks
 
Winston Gutkowski
Bartender
Pie
Posts: 10417
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ritesh raushan wrote:what is the difference between Composition vs Inheritance....thanks

I suspect that this is the 1,000,001st time this question has been asked. I suggest you search for other threads or paste your subject title into Google and find an explanation that you understand.

Winston
 
jatan bhavsar
Ranch Hand
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ritesh,

Inheritance is "IS-A" relationship like truck is a vehicle , while composition is "has-a" relationship like truck has a wheels. Inheritance means using the existing functionality while composition means you need to compose the functionality.

This article will give you the better understanding.

http://www.javaworld.com/jw-11-1998/jw-11-techniques.html
 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Ritesh raushan wrote:what is the difference between Composition vs Inheritance....thanks

I suspect that this is the 1,000,001st time this question has been asked. I suggest you search for other threads or paste your subject title into Google and find an explanation that you understand.

Winston




ok..thank you sir
 
Ritesh raushan
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jatan bhavsar wrote:Hi Ritesh,

Inheritance is "IS-A" relationship like truck is a vehicle , while composition is "has-a" relationship like truck has a wheels. Inheritance means using the existing functionality while composition means you need to compose the functionality.

This article will give you the better understanding.

http://www.javaworld.com/jw-11-1998/jw-11-techniques.html



Thank you very much...i am going to read on javaworld
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic