If I wrote a version of class "Hello" that implemented the Comparable interface, is this version of the Hello class "IS-A Hello" or "IS-A Comparable"

Viewed 35

I understand that the IS-A relationship is inheritance. So if I implemented the Comparable interface on a version of the Hello class, then is this version of the Hello class "IS-A Fraction," "IS-A Comparable," or would it fall under both of those categories?

1 Answers

Both.

Instantiating a Hello class creates a Hello object and implementing the Comparable interface makes it also a Comparable object. Per inheritance, this makes it possible for you to use the instantiated Hello object anywhere a Hello or Comparable instance can be used in your code.

Related