• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Q on Method Invocation !!

 
Reshma Shanbhag
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

The output is = b = 0 b = 16.
Please Explain me why its happening so
Thanks
reshma
[ March 27, 2003: Message edited by: Reshma Pai ]
 
Rajeshwari Natarajan
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both the base class and derived class contructors invoke the method call()..
since it is overridden in the derived class, and u r creating an object of the derived class, the derived class's call() method will be called twice.
The first time, an object of Q05 is not yet created and b value is not initialized to 16.
So 0 is printed.
[ March 27, 2003: Message edited by: Rajeshwari Natarajan ]
 
Reshma Shanbhag
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank for helping me out Rajeshwari.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic