• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Is this a subclass of Foo?

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The code can be found on page 467 of K&B 1.4:

class Food{
Popcorn p = new Popcorn() {
public void pop() {
System.out.println("anonymous popcorn");
}
};
}

It mentioned that an anonymous class is created and it is actually a SUBCLASS of Popcorn. I can understand this part.

Next on page 473 - Argument-Defined Anonymous Inner Class

b.doStuff(new Foo() {
public void foof() {
System.out.println("foofy");
} //end foof method
}); //end inner class def, arg, and end statement

My question is whether the anonymous class created within the arg, is a SUBCLASS of Foo?
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
YES..its a subclass of Foo. only difference is it is defined inside the argument.
 
Shanel Jacob
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for replying.
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic