This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP 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: 9528
32
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