Yes, an interface can extend another interface in Java. This is what the code for something like that would look like:
// this interface extends from the Body interface:public interface FourLegs extends Body{ public void walkWithFourLegs( );}
Remember that anyclass that implements an interface must implement the method headings that are declared in that interface. And, if that interface extends from other interfaces, then the implementing class must also implement the methods in the interfaces that are being extended or derived from. So, in the example above, if we have a class that implements the FourLegs interface, then that class must have definitions for any method headings inboth the FourLegs interface and the Body interface.
Would you like to thankProgrammerInterview.com for being a helpful free resource?Then why not tell a friend about us, orsimply add a link to this page from your webpage using the HTML below.
Link to this page:
Please bookmark with social media, your votes are noticed and appreciated: