extending Interface - multiple inheritance
In Java, interfaces can be extended using the extends keyword. This allows you to build a more complex interface by inheriting from one or more existing interfaces.
✅ Syntax for Extending Interfaces
Here, interface B extends interface A. So any class that implements B must implement both methodA() and methodB().
✅ Example
✅ Extending Multiple Interfaces
Java supports multiple interface inheritance, so one interface can extend multiple interfaces.
Any class that implements Z must provide implementations for methodX(), methodY(), and methodZ().
π« Note
-
You can only extend interfaces from other interfaces.
-
A class cannot extend an interface, it must implement it.
Comments
Post a Comment