• 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

anon class

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
I am not sure about these questions, please help.
1. anonymous inner class must extend some class.( is it the outer class)nad is it also true that it may not extend Object class.
2. anonynous class has no constructors.
3. we cannot instantiate an anonymous class.
thank you.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. An anonymous inner class either extends another class or implements a single interface (without using the keywords extend or implements). The base class need not be the enclosing class (although it could be), and could in fact be Object.
2. Because the anonymous class has no name, it can have no constructor (since constructors must share the name of their classes). However, it can be initialized using initializer blocks.
3. An anonymous class is instantiated by calling the constructor of the class it extends -- with the body of the anonymous class slipped in after the constructor's argument parentheses, but before the semicolon. The result is an instance of the anonymous class automatically upcast to the type of the base class.
 
sabah ammar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
alright...thank you very much
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic