Interview Question

How can Java implement multiple inheritance?

Use multiple interfaces and composition instead of extending multiple classes.

💡 Concept ✅ Quick Revision ☕ Java

Answer

Java represents multiple inheritance of type through interfaces. • A class can implement several interfaces. • An interface can extend several interfaces. • State and implementation should often be shared through composition rather than forced inheritance.

Example

Code
interface Printable { void print(); }
interface Savable { void save(); }
class Report implements Printable, Savable {
    public void print() {}
    public void save() {}
}

Quick Revision

Use multiple interfaces and composition instead of extending multiple classes.