You are here: Home / Topics / Simple interface example in Java

Simple interface example in Java

Filed under: Java on 2023-09-17 13:14:57

//  Program to use Simple Interface.


interface  AInterface
{
void showA();
}

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

class  InterfaceTest1
{
public static void main( String args[ ] )
{
 Test  t1 = new Test();
 t1.showA();
 
 AInterface  a1 = new Test();
 a1.showA();
 
 a1 = t1;
 a1.showA();
}
}


Output:

showA() of A interface.
showA() of A interface.
showA() of A 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. Share your stuff here so that others can get benefitted.