Java-Extend Interface

Extend Interface

Interface is also extended by other Interface. One Interface can inherit another by use of the keyword extends. This is much like a way for inheriting class. When you inheriting two interfaces, you must provide implementations for all methods defined within the interface inheritance path.

Program

0

Program Source

interface One {
   
    void methodOne();
}

interface Two extends One {

    void methodTwo();
}

class Test implements Two{
    
    public void methodOne()
    {
        System.out.println("methodOne called");
    }
    
    public void methodTwo()
    {
        System.out.println("methodTwo called");
    }
}

public class Javaapp {

    public static void main(String[] args) {
        
        Test f = new Test();
        f.methodOne();
        f.methodTwo();
    }
}

Leave a Comment