What is the output: prints:5 prints 6 prints 7 compile time error runtime error
i thought it will be compile time error as "abstract class cannot be instantiated". But its working fine . dont know why its working fine ? is it because it a anonymous inner class object of a abstract class.
SCJP 5.0<br /> <br />"Skills are started with learning and mastered with improvement. Nothing is hereditary except death" BUDDHA...
The anonymous class is actually a sub class of the abstract class.
Joined: Jul 24, 2007
but ahmed we are not extending it so is it implicitly being extended. and is it not instantiation? can you throw little more light on the topic.
And ahmed source of this request is javagalaxy which contains 500 java questions and all my questions are from that site. its a free registration under test your java skills section. I thought this might be helpfull to you or some one else... [ October 04, 2007: Message edited by: srinivas sridaragaddi ]
Joined: Apr 22, 2006
we are not extending it so is it implicitly being extended. and is it not instantiation?
Yes, thats the syntax for creating anonymous classes that extend their classes, Or implement their interfaces:
Here we are not instantiating the interface, we create anonymous implementer of Runnable.