Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OO Fundamentals

 
Abid Khal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What is true about has-a and is-a relationships? (Choose two)
A) Instance variables can be used when creating a has-a relationship.
B) Inheritance represents an is-a relationship.
C) Inheritance represents a has-a relationship.
D) Instances must be used when creating a has-a relationship.

The answer is A) and B).

But, I would have thought it was B) and D). Any idea's why I'm wrong?

Regards,
Abid

Edit: Adding source - Question is from www.scjptest.com
 
Mark Moge
Ranch Hand
Posts: 100
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can write this code and there is HAS A relationship without instances. So D is incorrect
You may use instances to show IS A relationship

 
Abid Khal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark,

I missed the key words...

A) Instance variables can be used when creating a has-a relationship.
D) Instances must be used when creating a has-a relationship.

Makes perfect sense now.
 
Ankit Garg
Sheriff
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abid please QuoteYourSources when you post a mock exam question...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic