File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to call parent class methods

 
Nilesh Srivastava
Ranch Hand
Posts: 70
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
Suppose there are four classes A, B extends A, C extends B and D extends D.
Now if I want to call A's method from D, will super.methCall() do?
or how to call the method.
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you do "super.methCall()" from class "D", the JVM will try and resolve it by first looking in class "C", then in class "B", and finally in class "A". It will call "A"-s version only if neither "B" nor "C" has over-ridden it.
If either "B" or "C" has overridden "methCall", there is no way to explicitly invoke "A"-s version from within "D".
[ October 17, 2003: Message edited by: Wayne L Johnson ]
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic