This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Can anybody please explain me what is the difference between composition and inheritance. I would appreciate the help from anybody. Thanks in advance, Prasad Bh.
prasad bhuvanam
Laojar Chuger
Ranch Hand
Joined: Dec 20, 2000
Posts: 111
posted
0
Basically, composition implements the relationship of "has a" and inhertance implements the relationship "is a".
Cindy Glass
"The Hood"
Sheriff
Joined: Sep 29, 2000
Posts: 8521
posted
0
Composition means that a class is composed of implementations of interfaces instead of inheriting those behaviors from some other class.
"JavaRanch, where the deer and the Certified play" - David O'Meara
David Roberts
Ranch Hand
Joined: Nov 03, 2000
Posts: 142
posted
0
An example of composition is the attribute reference, ie. composition: public class A { AnotherClass B = new AnotherClass(); } inheritance: public class A extends B { } or public class A implements B { }
------------------ David Roberts - SCJP2,MCP
David Roberts - SCJP2,MCP
prasad bhn
Greenhorn
Joined: May 04, 2001
Posts: 28
posted
0
Thanks for the replies friends. Best Regards, prasad bhn.