What types of inheritance does Java support, and which ones are impossible?
Java supports four of the five textbook forms, and bans the fifth for classes.
Single inheritance: a class extends exactly one superclass. This is the standard form — class Dog extends Animal.
Multilevel inheritance: a chain of classes, each extending the one before. Puppy extends Dog extends Animal. This is legal and extremely common in older code, though it produces the deep hierarchies discussed later in this topic.
Hierarchical inheritance: several subclasses sharing one superclass. Dog extends Animal and Cat extends Animal. This is the shape that makes polymorphism useful — a collection of the shared supertype holding different subtypes.
Multiple inheritance of interfaces: a class may implement any number of interfaces. class Dog extends Animal implements Pet, Trainable.
The form Java does not support is multiple inheritance of classes — a class cannot extend two superclasses. The reason is ambiguity: if both superclasses define a method, which one does the subclass inherit? The answer would have to depend on the order of the extends clause, which makes code brittle. Java's answer to that ambiguity is that classes inherit state, and state is where the ambiguity hurts.
There is one more form often mentioned that Java does not support directly: interface-to-interface multiple inheritance, where an interface extends several interfaces. Java does allow this — interface Diamond extends Left, Right — and it is where the interesting default-method rules live.