• 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

Annonymous classes

 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
annoymous classes must not have extend and implements clause
then if they want to extend or implement any class or interface then how do they do it.
Regards
neha
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First,I think annonymous class can't extend from other classs and implement any other interfaces.
Second,As me all know,if u wanna use a annonymous class,u should implement some kind of interface,so u can inherent the interface from other interface to implement all operations u wanna.
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
<code>Hi Neha :
Anonymous classes cannot have extends and implments clause doesn't mean that they cannot extend/implement the very fact when we instantiate the Anonymous class will tell you whether you extended a class or implemented an interface.
here is an example
class Nest{
public static void main(String argv[]){
Nest n = new Nest();
n.mymethod(new anon(){});
/*here the class is declared and instantiated at the same time
and it extends class called anon*/
}
public void mymethod(anon i){}
}
class anon{}
The answer to this question might be pretty long, but i suggest you to go thru' RHE book or any other book and you will understand.
</code>
[This message has been edited by Arsho, Ayan (edited December 16, 2001).]
reply
    Bookmark Topic Watch Topic
  • New Topic