
can we extend interface?

Hi Friend,
Yes an interface can be extended by other interface like using extends keyword
interface A{ }
interface B extends A{ }
For Example:
interface IntefaceA {
void method1();
void method2();
}
interface IntefaceB extends IntefaceA {
void method3();
}
class InterfaceExample implements IntefaceB {
public void method1() {
System.out.println("Method1.....");
}
public void method2() {
System.out.println("Method2.....");
}
public void method3() {
System.out.println("Method3.....");
}
public static void main(String arg[]) {
InterfaceExample ex = new InterfaceExample();
ex.method1();
ex.method2();
ex.method3();
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.