DEV Community

loading...

Important points for Java interface

Anand Singh
A neophyte✅ In love with java❤️⚡
・1 min read

interface I1
{
public void show();
//interface tells the class what to do
}
class Test implements I1
//for interface use implements keyword
{
public void show()
//It is necessary to create body of abstract method in child class
{
System.out.println("1");
}

public static void main(String[] args)
{
//We cannot create an object of interface so we have created the object of test class here
Test t=new Test();
t.show();

}
}

Discussion (0)

Forem Open with the Forem app