• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

anonymous inner classs extends Object or not ?

 
Vishy Karl
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
Why is the following statement false( as given in Bill Brogden's Exam Simulation Applet )
An anonymous inner class is always assumed to directly extend Object.
Is it not true when anonymous inner class does not extend anything else ?
Plz. explain,
Thanks in advance.
 
Vad Fogel
Ranch Hand
Posts: 504
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vishy Karl:

An anonymous inner class is always assumed to directly extend Object.
Is it not true when anonymous inner class does not extend anything else ?
Plz. explain,
Thanks in advance.

An anonymous inner class can either directly extend one class or directly implement one interface. Object is not necesserily an immediate superclass of an anonymous class, although it's always extended either directly or indirectly. Look at the following code:

Hope this helps.
 
Mohit Goyal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well anonymous classes r either a subclass of a class or an implementer of an interface.
in both the cases it represents a class and since all classes implicitly extend from Object so anonymous classes extend Object implicitly.
 
Derek Baker
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think it is wrong to say that it is assumed to directly extend Object. Directly implies (I think) that it is one level below Object and extends nothing else. And you can't assume that.
 
Vishy Karl
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for clearing the confusion,
Byeeee
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic