• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Danchisholm question - Anonymous Classes

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

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

Can someone explain please !

Thanks

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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I hope this code answers your doubt.

thanks,
vinu.
 
P Hunjan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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

Thanks
 
reply
    Bookmark Topic Watch Topic
  • New Topic