Using anonymous Inner class concept we can create an object for an interface…..
Here is a sample code
interface Sample {
public void method();
}
class Outer {
Sample s = new Sample() {
public void method() {
System.out.println("Inner class");
}
};
}
public class Example {
public static void main(String args[]) {
Outer o = new Outer();
o.s.method();
}
}
Output: Inner class