Difference between type inheritance and implementation inheritance

Asked

Viewed 994 times

3

My teacher passed a booklet on Object Oriented Data Structure with Java and in the booklet there is an excerpt (without deepening) that says the following:

"Interface promotes heritage of type and not heritage of implementation; "

What is the difference between these two types of inheritance?

1 answer

4


This booklet is out of date today interface may have implementation.

Inheritance of type is to take over the contracts that a type offers, ie to have guaranteed all the methods with your signatures of a type in a new type. The type inherits what has already been declared in another type.

Implementation inheritance takes the algorithm, the code it executes in the methods, and can even receive implementation details like the type fields. Interface has never been.

Implementation inheritance has to do with object orientation. Type inheritance has to do with static typing, or at least safe typing.

This can be useful.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.