+ 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.

21st Apr 2017, 3:18 PM
Preet Patel
Preet Patel - avatar
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.
22nd Apr 2017, 8:08 AM
Preet Patel
Preet Patel - avatar