| Author |
"IS-A" and "HAS-A" doubt
|
Kedar Pethe
Ranch Hand
Joined: Jul 17, 2012
Posts: 39
|
|
K&B question in self test-
Q - You’re designing a new online board game in which Floozels are a type of Jammers, Jammers can
have Quizels, Quizels are a type of Klakker, and Floozels can have several Floozets. Which of the
following fragments represent this design?
Why isn't Fragment 4 one of the correct answers??
|
 |
Pritish Chakraborty
Ranch Hand
Joined: Jun 12, 2012
Posts: 91
|
|
Because Floozel does not HAVE-A Floozet.
Here it IS-A Floozet.
|
OCJP 6
|
 |
Kedar Pethe
Ranch Hand
Joined: Jul 17, 2012
Posts: 39
|
|
Pritish Chakraborty wrote:Because Floozel does not HAVE-A Floozet.
Here it IS-A Floozet.
oh.. So simple!!
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Pritish Chakraborty wrote:Because Floozel does not HAVE-A Floozet.
Here it IS-A Floozet.
Floozel HAS-A Floozet as per the question. The point here to take away is the following:
(1) IS-A relationship represents Inheritence
(2) HAS-A relationship represents Composition
Hope that was clear.
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Pritish Chakraborty
Ranch Hand
Joined: Jun 12, 2012
Posts: 91
|
|
I'm sorry, I didn't get you....
Of course those two points are very clear but here Floozel and Floozet are two interfaces linked through inheritance, not through composition.
How does the HAS-A relationship come into question at all?
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Pritish Chakraborty wrote:I'm sorry, I didn't get you....
Of course those two points are very clear but here Floozel and Floozet are two interfaces linked through inheritance, not through composition.
How does the HAS-A relationship come into question at all?
Doesn't this sentence say that?
I would infer the following:
Quizels extends Klakker (are a type of Klakker) and when Floozels can have several Floozets, would mean Floozels has one to many Floozets as its member. How could I apply IS-A relationship here? Do you understand it now?
By the way, Answer option 4 is wrong. Any wrong answer in the SCJP exam is just to confuse you. The interface in the option 4 above is also to confuse you.
|
 |
Pritish Chakraborty
Ranch Hand
Joined: Jun 12, 2012
Posts: 91
|
|
My dear sir, with all due respect, I did read the question. I don't know if you did however.
The original poster was asking why the fourth fragment was wrong.
And it is wrong because the HAS-A relationship of Floozel and Floozet is NOT maintained, which is required as per the question.
It does not hurt to reread the query
Yes, we know option 4 is wrong. He was asking why it is wrong.
Good day to you, sir.
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Pritish Chakraborty wrote:My dear sir, with all due respect, I did read the question. I don't know if you did however.
The original poster was asking why the fourth fragment was wrong.
And it is wrong because the HAS-A relationship of Floozel and Floozet is NOT maintained, which is required as per the question.
It does not hurt to reread the query
Yes, we know option 4 is wrong. He was asking why it is wrong.
Good day to you, sir.
I don't get you. If you understood the question, then why ask the following in your post above?
|
 |
Pritish Chakraborty
Ranch Hand
Joined: Jun 12, 2012
Posts: 91
|
|
Let me clarify this confusion once and for all.
My reply to the OP's query was with respect to the code fragment he posted. He asked why it is wrong.
I answered why it is wrong.
The quote of my post which you have put in </code> tags was asked to you : because you were stating the obvious, and not answering the OP's query.
You were informing me what IS-A and HAS-A relationships are about, whereas the thread had gone in a completely different direction and had already been resolved.
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Pritish Chakraborty wrote:Let me clarify this confusion once and for all.
My reply to the OP's query was with respect to the code fragment he posted. He asked why it is wrong.
I answered why it is wrong.
The quote of my post which you have put in </code> tags was asked to you : because you were stating the obvious, and not answering the OP's query.
You were informing me what IS-A and HAS-A relationships are about, whereas the thread had gone in a completely different direction and had already been resolved.
The idea here is to mention about composition and Inheritence which I felt I did!
|
 |
 |
|
|
subject: "IS-A" and "HAS-A" doubt
|
|
|