by Dinesh Thakur

This JavaInterfaceExample shows, An interface is a blueprint of a class. its functions should be public and abstract. We use the interface Keyword to define an interface. if a class implementing an interface should use the implements keyword as we see in our example class JavaInterface implements InterfaceExample . No need to creating objects for an interface. Interfaces don't have constructors as they can't be initiated. An Interface can be extends by one or more interfaces.

Here is the Java Example for the program JavaInterfaceExample :

interface InterfaceExample

{
             public void msg();
}
class JavaInterface implements InterfaceExample
{
            public void msg()
        {
             System.out.println("Java Interface Example !");
        }
}
class JavaInterfaceExample
 {
      public static void main(String args[])
    {
        InterfaceExample Showable=new JavaInterface();
        Showable.msg();
    }
}

Java Interface Example