Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes anonymous inner classs extends Object or not ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "anonymous inner classs extends Object or not ?" Watch "anonymous inner classs extends Object or not ?" New topic
Author

anonymous inner classs extends Object or not ?

Vishy Karl
Ranch Hand

Joined: Sep 08, 2003
Posts: 116
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.


"The man who can drive himself further once the effort gets painful is the man who will win." <br />Roger Bannister
Vad Fogel
Ranch Hand

Joined: Aug 25, 2003
Posts: 504
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

Joined: Nov 09, 2003
Posts: 65
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

Joined: May 23, 2003
Posts: 46
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

Joined: Sep 08, 2003
Posts: 116
Thanks a lot for clearing the confusion,
Byeeee
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: anonymous inner classs extends Object or not ?
 
Similar Threads
question on anonymous class
Double-standard for anonymous inner class extending directly from Object class
Anonymos Class
anonymous inner class
Anonymous class....