This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Danchisholm question - Anonymous Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Danchisholm question - Anonymous Classes" Watch "Danchisholm question - Anonymous Classes" New topic

Danchisholm question - Anonymous Classes

P Hunjan

Joined: May 20, 2005
Posts: 16

The following question's correct answers are b & d.
I am not able to understand how option d. is correct.

Can someone explain please !


Which of the following are true statements?

a. An anonymous class is implicitly abstract.
b. An anonymous class is implicitly final.
c. An anonymous class is implicitly static.
d. A static reference variable can reference an instance of an anonymous class.
e. An anonymous class declaration must have at least one explicit constructor declaration.
f. An anonymous class declaration can have more than one explicit constructor declaration.
vinuharan haran
Ranch Hand

Joined: Feb 26, 2005
Posts: 64
I hope this code answers your doubt.

P Hunjan

Joined: May 20, 2005
Posts: 16
Thanks a lot for your reply.

I was guessing that when we create an anonymous class in static context. The anonymous class also implicitly gets the status of being static and in this situation the static reference can refer to this anonymous class.

But I tried writing code, where an anonymous class in non-static context is refered by a static reference & obviously it didnt work.

So I am still confused ?

And theres one more question related to this.
Local & anonymous classes cannot be marked as static but they can be created in static context & then they are implicitly static.

So why is that constraint ?

Would be great if someone can throw some light on this

wood burning stoves
subject: Danchisholm question - Anonymous Classes
Similar Threads
InnerClass tell me the ans
anonymous class doubt
Another anoymous question
anonymous class question