• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Determining IS-A & HAS-A Relationship when using Abstract Classes / Interfaces

 
Ehsan Rahman
Ranch Hand
Posts: 59
Chrome Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Dog 'Is-A' animal.
Dog 'Has-A' dog collar.

However, is there any determination of IS-A or HAS-A relationship when using Abstract Classes?



Q's:
- Does RoboDog 'Have-A' barkLoudness of 5?
- Does RoboDog 'Have-A' or 'IS-A' bark() ?
- What about Interface methods and static variables if RoboDog were to implement them? Would they be considered 'HAS-A' or 'IS-A'?

Links to articles would also be helpful please.

Thanks in advance,
Ehsan
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does RoboDog 'Have-A' barkLoudness of 5?
- Does RoboDog 'Have-A' or 'IS-A' bark() ?

Ehsan, you are misinterpreting the IS A and HAS A relationship. They are not comparable with state and behaviour of Class.
Please have look at IS-A and HAS-A.



Here Dog extends Animal and Dog is an instance of Animal. This is IS-A relationship.



Here Dog has an instance of Collar class. This is HAS-A relationship.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic