• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"IS-A" and "HAS-A" doubt

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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??
 
Ranch Hand
Posts: 91
Firefox Browser C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because Floozel does not HAVE-A Floozet.

Here it IS-A Floozet.
 
Kedar Pethe
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pritish Chakraborty wrote:Because Floozel does not HAVE-A Floozet.

Here it IS-A Floozet.



oh.. So simple!!
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Pritish Chakraborty
Ranch Hand
Posts: 91
Firefox Browser C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 91
Firefox Browser C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 91
Firefox Browser C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 San
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic