Interfaces Can Be Extended

One interface can inherit another interface with the keyword extends.

 
interface IntefaceA {
  void meth1();
  void meth2();
}
interface IntefaceB extends IntefaceA {
  void meth3();
}
class MyClass implements IntefaceB {
  public void meth1() {
    System.out.println("Implement meth1().");
  }
  public void meth2() {
    System.out.println("Implement meth2().");
  }
  public void meth3() {
    System.out.println("Implement meth3().");
  }
}
public class Main {
  public static void main(String arg[]) {
    MyClass ob = new MyClass();
    ob.meth1();
    ob.meth2();
    ob.meth3();
  }
}

The output:


Implement meth1().
Implement meth2().
Implement meth3().
Home 
  Java Book 
    Class  

Interface:
  1. What is a Java Interface
  2. Implementing Interfaces
  3. Accessing Implementations Through Interface References
  4. Partial interface Implementations
  5. Variables in Interfaces
  6. Interfaces Can Be Extended