Extending Interfaces:
An interface can extend another interface to inherit its property, in this case we have to use “extends” keyword:
interface My {
void show();
}
interface My1 extends My
{
void display();
}
public class MyImpl implements My1
{
public void show() {
System.out.println("Show method called.");
}
public void display()
{
System.out.println("Display method called.");
}
public static void main(String args[])
{
My1 m1 = new MyImpl();
m1.show();
m1.display();
}
}
Output:
Show method called.
Display method called.
No comments:
Post a Comment