aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes inner class mock exam question 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 "inner class mock exam question" Watch "inner class mock exam question" New topic
Author

inner class mock exam question

Stephanie Grasson
Ranch Hand

Joined: Jun 14, 2000
Posts: 347
This is from the mock exam at http://www.geocities.com/SiliconValley/Screen/5046/ftest1.html.
The directions say to check all of the following statements which are true:
1. An inner class can have the same name as its enclosing class.
2. An instance of a non-static inner class always has an associated instance of the enclosing class.
3. An anonymous inner class is always assumed to extend Object.
According to the results, only answer #2 is correct.
But don't ALL objects extend Object?
Please advise.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Class Object begets all other classes. Even if your annonymous class implements an interface, your class extends Object. So, option #3 is correct.
Nirmala
Ranch Hand

Joined: Jun 28, 2000
Posts: 93
Stephanie Grasson,
The given answer is correct. You have to read the question carefully,what it says is
An anonymous inner class is always assumed to extend
Object.
Not necessarily Always,
Anonymous class can extend to other class also.
That is why the answer is '2'.
Hope this may help to some extend.
Thanks
Nirmala
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
But aren't you still extending Object in that case? It may not be the immediate parent, but it's being extended, nonetheless.
hemanshow
Greenhorn

Joined: Jun 26, 2000
Posts: 25
anonymous class can:
1. either implement an interface
2. or extend an abstract class.
I think, always assumed means that if anonymous class is not made from an abstract class, it extends Object. The requirement to assume will only arise when U dunno which class it extends to (i.e. interfae).
so answers 2,3 should be right.
rajsim
Ranch Hand

Joined: May 31, 2000
Posts: 116
We should take "extend" as a specific word which relate class
and its immediate parent class as Java uses "extends" for this purpose.
[This message has been edited by rajsim (edited July 20, 2000).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inner class mock exam question