EMZETT.
Login

Multiple Inheritance

In short: Multiple inheritance means a class inherits from several superclasses.

In more detail: Java forbids this for classes to avoid the diamond problem: if a class inherits the same method via two paths, it is unclear which one applies. Languages like C++ and Python allow it.

In Depth

Solution in Java

A class may implement several interfaces. Since Java 8 interfaces have default methods (default); in case of conflicts the class must override the method itself.

class Duck extends Animal implements Flying, Swimming { }

See inheritance, extends.

See also: Inheritance, extends, Interface