In C# you can call a method of any ancestor like this:
public class A internal virtual void foo() ... public class B : A public new void foo() ... public class C : B public new void foo() { (this as A).foo(); }
Also you can do this in Delphi:
type A=class procedure foo; ... B=class(A) procedure foo; override; ... C=class(B) procedure foo; override; ... A(objC).foo();
But in Java you can do such focus only by some gear. One possible way is:
class A { int y=10; void foo(Class X) throws Exception { if(X!=A.class) throw new Exception("Incorrect parameter of "+this.getClass().getName()+".foo("+X.getName()+")"); y++; System.out.printf("A.foo(%s): y=%d\n",X.getName(),y); } void foo() throws Exception { System.out.printf("A.foo()\n"); this.foo(this.getClass()); } } class B extends A { int y=20; @Override void foo(Class X) throws Exception { if(X==B.class) { y++; System.out.printf("B.foo(%s): y=%d\n",X.getName(),y); } else { System.out.printf("B.foo(%s) calls B.super.foo(%s)\n",X.getName(),X.getName()); super.foo(X); } } } class C extends B { int y=30; @Override void foo(Class X) throws Exception { if(X==C.class) { y++; System.out.printf("C.foo(%s): y=%d\n",X.getName(),y); } else { System.out.printf("C.foo(%s) calls C.super.foo(%s)\n",X.getName(),X.getName()); super.foo(X); } } void DoIt() { try { System.out.printf("DoIt: foo():\n"); foo(); Show(); System.out.printf("DoIt: foo(B):\n"); foo(B.class); Show(); System.out.printf("DoIt: foo(A):\n"); foo(A.class); Show(); } catch(Exception e) { //... } } void Show() { System.out.printf("Show: A.y=%d, B.y=%d, C.y=%d\n\n", ((A)this).y, ((B)this).y, ((C)this).y); } }
objC.DoIt() result output:
DoIt: foo(): A.foo() C.foo(C): y=31 Show: A.y=10, B.y=20, C.y=31 DoIt: foo(B): C.foo(B) calls C.super.foo(B) B.foo(B): y=21 Show: A.y=10, B.y=21, C.y=31 DoIt: foo(A): C.foo(A) calls C.super.foo(A) B.foo(A) calls B.super.foo(A) A.foo(A): y=11 Show: A.y=11, B.y=21, C.y=31
super.super.toString()contradicts your own decision when you choose to extend a class thus accepting all (not some of) its features.