Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on anonymous class

 
Yuva Raj Sah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For the code:

The output is:
Super method
Sub method

Does that mean the reference s refers to the anonymous sub class ? a bit confused.

(code tags added)
[ May 21, 2004: Message edited by: Barry Gaunt ]
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code makes a new object from a subclass of class Super. The new subclass has been provided with a new implementation of method method1 which overrides the base class' implementation. Then that new object has been assigned to the variable s which is of type Super, the base class. When s.method1() is executed, the subclass' version of method1 gets called (normal polymorphism behaviour).
 
Yuva Raj Sah
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for clarification.

Yuvaraj
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic