Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!