Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

is a relationship  RSS feed

 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which two demonstrates �is a� relationship

A.public interface Person { }
public class Employee extends Person { }

B. public interface Shape { }
public class Employee extends Shape { }

C. public interface Color { }
public class Employee extends Color { }

D. public interface Species { }
public class Animal { private Species species;}

E. interface component { }
class container implements component { private component [] children;}


Ans: D, E

I did not understood meaning of this type of question; it would be nice if someone can help me. What exact meaning of is arelationship?

Thank you in advance.
 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A/B/C are wrong bcoz a class cant extend an interface.
moreover I am still wondering how D & E r right opton.
 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hint: IS A relationship can be tested by using instanceof operator

Try that
 
Nitin Bhagwat
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Jay
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder that the option D as well is wrong since that would be of the type : "has a" relation rather than "is a" relation.

Inheritance can be said as is a relation while aggregation can be said as has a relation.

let me know if this is ok..
Murali
 
Ranch Hand
Posts: 1392
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Muralidhar. Option D represents a "HAS-A" relationship.
 
Ranch Hand
Posts: 298
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we could know the source of this question then it would be easy to find out what exactly was the question.

It may have asked for only 1 option right.

kaps
 
You ridiculous clown, did you think you could get away with it? This is my favorite tiny ad!
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!