You are here: Home / Topics / Program to explain Inheritance of a interface in Java

Program to explain Inheritance of a interface in Java

Filed under: Java on 2023-09-17 13:16:47

//  Program to explain Inheritance of a interface
//  from another interface.

interface AInterface
{
void showA();
}

interface BInterface extends AInterface 
{
void showB();
}

class Test  implements BInterface
{
public void showA()
{
 System.out.println("showA() of A interface.");
}

public void showB()
{
 System.out.println("showB() of B interface.");
}
}

class InterfaceTest4
{
public static void main( String args[ ] )
{
 AInterface  a1 = new Test();
 a1.showA();
 
 BInterface b1 = new Test();
 b1.showA();
 b1.showB();
}
}


Output:

showA() of A interface.
showA() of A interface.
showB() of B interface.

About Author:
M
Mr. Dubey     View Profile
Founder of MCQ Buddy. I just like to help others. This portal helps students in getting study material free.