aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Annonymous Class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Annonymous Class" Watch "Annonymous Class" New topic
Author

Annonymous Class

Mukesh Rathod
Ranch Hand

Joined: Oct 11, 2000
Posts: 32
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

Joined: Sep 23, 2000
Posts: 3325
    
    8
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


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
bill bozeman
Ranch Hand

Joined: Jun 30, 2000
Posts: 1070
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

Joined: Sep 23, 2000
Posts: 3325
    
    8
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

Joined: May 05, 2000
Posts: 13974
The question is poorly worded. Every class extends object so it should be true.


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Mukesh Rathod
Ranch Hand

Joined: Oct 11, 2000
Posts: 32
yes, that should be the correct answer.
thanks all.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Annonymous Class