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

is-a relationship always relies on polymorphism

 
Ali Khalfan
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This statement comes from K & Bs master exam.

IS it true? why does it ALWAYS rely on polymorphism?

What does the statement mean anyway?
 
Matt Russell
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately, it's a bit of a vague and confusing statement. In good object-oriented design, you express an "is-a" relationship using subclassing. Polymorphism is a mechanism that lets you treat instances of subclasses of a particular class as if they were instances of that class itself. So I think you could say that classes in an "is-a" relationship can, and should, take advantage of polymorphism, and that's perhaps what the K&B statement was getting at.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic