Alex Rivera | Logout

Why is there no multiple inheritance in Java, but implementing multiple interfaces is allowed?

Asked 2010-03-25T12:40:41.557
199

Java doesn't allow multiple inheritance, but it allows implementing multiple interfaces. Why?

Edit
Report

1 Answer

-1

Take for example the case where Class A has a getSomething method and class B has a getSomething method and class C extends A and B. What would happen if someone called C.getSomething? There is no way to determine which method to call.

Interfaces basically just specify what methods a implementing class needs to contain. A class that implements multiple interfaces just means that class has to implement the methods from all those interfaces. Whci would not lead to any issues as described above.

answered 2010-03-25T13:08:37.570

Your Answer