Multiple Inheritance Using Interfaces in Java



Java does not support multiple inheritance. This means that a class cannot extend more than one class. Therefore, following is illegal −

Example

public class extends Animal, Mammal{}

However, a class can implement one or more interfaces, which has helped Java get rid of the impossibility of multiple inheritance.
The extends keyword is used once, and the parent interfaces are declared in a comma-separated list.
For example, if the Hockey interface extended both Sports and Event, it would be declared as −

Example

public interface Hockey extends Sports, Event
Updated on: 2020-02-25T12:33:24+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements