Interface

Author: Ravi Poswal

A class's blueprint is an interface. It is 100% abstract class, i.e., all methods (in the interface) do not have anybody (information), but these are implemented in another class. Java interface also represents the IS-A relationship.Interface support all functionality of multiple inheritances. As you know, java has not support multiple inheritances, but these functions can be used via an interface.

Syntax:-       interface <interface-name>

{                }

An interface can extend another interface, and a class can be extended to another class. But a class puts an interface into practice.

interface A

                           {  void add();

                              void sub();

                            }

Code Example

interface A
{
public void run();
}
class B implements A
{
public void run()
{
System.out.println("run method in interface body"); 
}
public static void main(String arg[])
{
B x=new B();
x.run();}
}
}