+ 1
Java Anonymous Class
Consider following code :- abstract class AbstractClass { abstract void m1(); } class Test { public static void main (String [] args) { AbstractClass obj = new AbstractClassâ(){ @Override void m1() { System.out.println("Instance of abstract class !"); } }; obj.m1(); } } Now how this works.
2 Answers
0
Thanks @Tasha, i figured out we can create an instance of anonymous class which extends it parent reference but i was not exactly sure how it worked, so i thought SOLOLEARN would work to help me clarify this, and it indeed worked. Thanks again.