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

calling super class methods

 
kau kau
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
could anyone help with this...
I'm calling a super class method.Now, i want this method to call other super class methods..instead it calls the subclass method.(all methods in the superclass are overridden in the subclass).
the expected ouput is -
in C.m1
in P.m2
in P.m1
instead it goes in a loop...
in C.m1
in P.m2
in C.m1
in P.m2....
following is the code -
class P
{
public void m1()
{
System.out.println("In P.m1()");
}
public void m2()
{
System.out.println("In P.m2()");
m1();
}
}
public class C extends P
{
public void m1()
{
System.out.println("In C.m1()");
super.m2();
}

public void m2()
{
System.out.println("In C.m2()");
}
public static void main(String[] args)
{
C c = new C();
c.m1();
}
}
 
Chris Harris
Ranch Hand
Posts: 231
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
This topic has been crossed post and has been answered in "Java in General (intermediate)".
[ added link -ds ]
[ January 08, 2004: Message edited by: Dirk Schreckmann ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks for the heads up, Chris.
kau, please don't post the same question in multiple forums. It just makes it difficult to follow a conversation and uses Ranchers' efforts needlessly.
I'm closing this thread.
 
    Bookmark Topic Watch Topic
  • New Topic