Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Java 8 support multiple inheritance? [duplicate]

Tags:

java

I have come across this topic while reading interface in Java 8, there are scenarios where we define method in interface using default or static keyword, allowing the next child to either re-define the same method or implement it. Does that means multiple inheritance? There's one more issue that I found is that, return type must be co-variant type else compile issue, that means it still doesn't support multiple inheritance? Can we say that java supports multiple inheritance? Let me know more details in regard to this topic.

like image 344
Nizamuddin Shaikh Avatar asked Apr 29 '16 06:04

Nizamuddin Shaikh


1 Answers

Does that means multiple inheritance?

For interfaces, yes, but not classes. It is usually classes people think of as only classes can have fields and constructors. This is no different to Java 1.0

return type must be co-variant type else compile issue, that means it still doesn't support multiple inheritance?

The need for covariant returns type is not related to whether you have multiple inheritance or not.

Can we say that java supports multiple inheritance?

For interfaces, yes.

like image 159
Peter Lawrey Avatar answered Nov 07 '22 03:11

Peter Lawrey