... if code defines an is-a relationship
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
maybe this is a foolish question, but I was really surprised about the answer in the Mughal/Rasmussen book (Q. 7.37):
This is the (EDIT) statement (formerly: answer) I am confused about:
(b) The code defines a Planet is-a Star relationship.
This statement is wrong according to the solution.
So guys (and girls). For this answer to be true it is not enough to have the class Planet to subclass the class Star? We need to have a reference value of type Star which references to a object of type Planet? Like the out commented part in the code?
I just want to be 100% sure.
Thanks
Bob
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That wasn't a foolish question. I was just too clever for this Mughal/Rasmusseen book.
I was right in the first place. Of course this code defines a Planet is-a Star relationship. But there was a BIG typo in the question and answer.
Here is his link to the Errata: Mughal's errata
cheers
Bob
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
What would be the answer for this :-
class B "Is-A/Has-A or Uses-A" A?
SCJP 5.0
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Ankit Garg wrote:When a class has a reference to another class, it is HAS-A relationship. IS-A relationship is always defined by inheritance. So the book is correct...
Thanks for your fast answer. I didn't quote my question good enough. I edited it now in my first post. This was the statement, which the solution negated to
The code defines NOT a Planet is-a Star relationship
But that was a type (my previous post).
cheers
Bob
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
cheers
Bob
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
but anyway, the best thing is you got the concept
...SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
@Bob,
I feel what you are talking about refers to polymorphism.According to me the given is correct.
Enjoy, Chander
SCJP 5, Oracle Certified PL/SQL Developer
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I try to state the question from the book again, regarding the code from post 1:
Which statements about the program [upper code] are true?
...
(b) The code defines a Planet is-a Star relationship.
...
I thought, yeah sure, BUT, and here came my confusion, the solution (from the book) said to me: NOPE this is wrong.
And I began to think (
); always bad. After I've written my upper post I found the error list to the book (Errata Link). So in the end, of course (
) statement (b) is true.
@Bob,
I feel what you are talking about refers to polymorphism.According to me the given is correct.
Yep. That's right. Mughal/Rasmussen are wrong, we are right !!!
Sorry again about that confusion again
Bob
SCJP 6 - SCJD - SCWCD 5 - SCBCD 5
JavaEnterpriseEditionFaq - TomcatFaq
| Do you want ants? Because that's how you get ants. And a tiny ads: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











