by Dinesh Thakur Category: Data Type

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



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.