Interface and its implementation

What is an interface and how will you go about implementing an interface?

Interface is a set of protocols which are used to define the structure of an application. They support multiple interface inheritance. An interface can contain variable. These variables by default are public static final. Interfaces are by default abstract. An interface can contain only abstract methods. Interfaces are implemented in class by using the implements keyword. In interfaces the methods or functions are declared only, they are defined in the class.

For example
Interface a

{

   Int n1=5;

   Void s();

   Void s1();

}

//full implementation of the interface

class b implements a

{

   public void s()

   {

       System.out.println(“Hello s”);

   }

   public void s1()

   {

       System.out.println(“Hello s1”);

   }

   public static void main(String args[])

   {

       System.out.println(n1);

       int c=n1*n1;

       System.out.println(c);

       b obj= new b();

       obj.s();

       obj.s1();

   }

}
Difference between Static and Non-Static fields of a class.
Static and Non-Static fields - Static variables or fields belong to the class, and not to any object of the class...
What are Class loaders? Explain the types of class loader
What are Class loaders? - Class loaders are the part of the Java Runtime Environment that dynamically loads Java classes....
Dynamic loading
Dynamic loading - Classloader and its method LoadClass() is used for dynamic loading of a class...
Post your comment