ProgrammingHardProduct-company placement · GATE CS

Classes A, B extends A and C extends B all override m(). Inside C, which way can call A's version of m() on the current object?

  1. A. super.super.m()
  2. B. ((A) this).m()
  3. C. A.super.m()
  4. D. None directly; C can only reach B's version through super.m()

Correct answer: D. None directly; C can only reach B's version through super.m()

Java has no super.super; ((A) this).m() still dispatches to C.m() and would recurse. A.super.m() is legal only for a directly implemented interface's default method. B must expose its own call to super.m() if C needs it.

More OOP with C++ and Java questions

Exams that ask this topic