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 Get Programming with Java (MEAP only) this week in the Beginning Java 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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
 
Water! People swim in water! Even tiny ads swim in water:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!