1

Is there any notion of " Interface inheritance is public inheritance, while implementation inheritance is private inheritance" in java?

I have read this post.

Community
  • 1
  • 1
sumit
  • 133
  • 2
  • 10

1 Answers1

0

I read the post you linked. In this post, Péter Török states about Private Inheritance the following:

However, if B privately inherits from A, B is-implemented-in-terms-of A: only the implementation of A is inherited, not its interface. Thus (references/pointers to) B objects can not be used in places where A objects are expected.

I don't think there is such thing in Java as Private Inheritance, at least in the terms expressed above.

So, after reading the post and considering that in Java:

  • Interface Inheritance is related to interfaces and classes implementing this interfaces, and
  • Implementation Inheritance is related to class specialization

I think it is not possible the case where you create a Class B that implements an Interface A or extends a Class A, and this Class B couldn't be used as A.

malaguna
  • 4,183
  • 1
  • 17
  • 33