| Author |
Has-a relationship
|
Stary Kapec
Ranch Hand
Joined: Dec 04, 2005
Posts: 81
|
|
class A {} class B extends A {} class C { B b; } C has-a B, but my doubt is if C has-a A is also true, because B extends A Thanks
|
 |
Gavin Tranter
Ranch Hand
Joined: Jan 01, 2007
Posts: 333
|
|
I would have guessed that C HAS-A A, as B IS-A. But the reference is actual to a class of type B, therefore I would say C dosnt HAVE-A A. But that is just my guess, would like to know what others think  [ March 20, 2007: Message edited by: Gavin Tranter ]
|
 |
Srinivasan thoyyeti
Ranch Hand
Joined: Feb 15, 2007
Posts: 557
|
|
Yes. C has A through B, would be more proper. There is difference in saying "C has A" and "C has A through B." 1)C has A: Here A's methods will work on its data. 2)"C has A through B." : when Method overriding takes place, "B method may include its own data too". Hope its clear.
|
Thanks & Regards,<br />T.Srinivasan,<br />SCWCD 1.4(89%),SCJP 5.0(75%)<br />"That service is the noblest which is rendered for its own sake." - Mahatma Gandhi
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Has-a relationship
|
|
|