How to Create an Interface and Implement it in Core Java

In this tutorial how to create a Interface and implement in Core Java  is shown.

Code:

Interface.java

interface Test
{
abstract public void disp();
}

class A
{
int a=100;
}

class Dummy extends A implements Test
{
public void disp()
{
System.out.println(“Inside Interface”);
}
}

class TestInterface
{
public static void main(String args[])
{
Dummy d=new Dummy();
d.disp();
System.out.println(“A: “+d.a);
}
}

Add a Comment

Your email address will not be published. Required fields are marked *