• 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

Overriding

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more question for today.....if I have overridden a base class method, and I have a derived class object, is there any way I call invoke the base class version?
Please somebody help me out......thanx
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gopinath Rajgopal:
One more question for today.....if I have overridden a base class method, and I have a derived class object, is there any way I call invoke the base class version?
Please somebody help me out......thanx


if you have amethod() in both the base and derived class and want to exectue the amethod() in base from inside the derived class, use
super.amethod();
If you want to execute the a method in base from another class, you have to create a base object (not a base object refernce to a derived object) ie
base b = new base();
b.amethod();

[This message has been edited by Carl Trusiak (edited June 29, 2000).]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adding on to Carl's response...
If you have a derived class object and you are writing code outside the derived class definition, there is no way you can use the derived class object to access the base class method. It's gone, completely replaced by the derived method.
 
reply
    Bookmark Topic Watch Topic
  • New Topic