• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Annonymous Class

 
Mukesh Rathod
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of the question of Bill Brodgen's Mock exam one option is :
An annonymous inner class is always assumed to extend Object
Answer is false.
The explaination given is : Answer is wrong as an annonymous inner class can extend any class, however the declaration syntax does not use the wrod extends.
This is not clear to me.
Can anybody explain this?
Thanks.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a small program...

Here, you can see that the inner class extends class A.
You can verify it by doing :
javap Test$1
HTH,
Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus
 
bill bozeman
Ranch Hand
Posts: 1070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But aren't all classes subclasses of Object by default. I would think it would be true because any class you create extends Object. I know that for an Annonymous class you have to extend a class or implement an interface, but everything always leads back up to the Object superclass. Am I correct in this?
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3714
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that is correct but that's not what the author probably meant. I think, he wanted to drive the point that Anonymous class can extend any other class also.
-Paul.

------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question is poorly worded. Every class extends object so it should be true.
 
Mukesh Rathod
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, that should be the correct answer.
thanks all.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic