• 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

Anounymous inner class

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In a mock exam I came accross this:
'An anomymous inner class is allways assumed to extend Oblect'
I thought it to be right. But no. Why?
In my opinion all classes extend Object...
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it can also extend a class other than "Object".
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!
In my opinion :
The question asks if anonymous inner class extends Object by default.
I think it has to be looked at in this manner:
Take anonymus class made for Action Listeners
eg:
myButton.add(.. the anonymous class written for actionlist..);
here the direct extended class is not Object but EventListener for ActionListener interface.

Any body else on this am i on track or shot into different orbit...
Ashish T.
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's a badly phrased question. By "extends" do they mean "directly extends" only, or can they also mean "indirectly extends"? We can't really know. (Well, I guess we can after reading the answer, but it's still a bad question.) All anonymous classes extend Object at least indirectly, but they only dirctly extend Object if (a) they explicitly name Object as the class they extend, or (b) they name an interface to implement instead. In the latter case Object is the class extended, by default.
reply
    Bookmark Topic Watch Topic
  • New Topic