How do I create an Interface Object?

An object of the Interface can be created using the help of the class that implements the interface.

For example:


An Interface A

Interface A {

String retval(String value);


Let Class B implement Interface A

Class B implements A {

Public String retval(value)


Return value;



Then the Interface Object can be called by:

A obj = new B();

In short the General format for Declaring an Object of Interface is :

Interface interfaceObject = new ClassImplementingInterface();