class A
{
public void Foo() {}
}
class B extends A
{
}
class C extends B
{
public void Foo() {}
}
Does C’s Foo() override A’s even though B did not override it? Or do I have to add a stub in B that calls the super’s method for each one I want to override in C?
Even though B did not mention it,
Fooshould still be available to it due to inheritance. By extension, then,Foois also available to subclass C and should be able to be overridden thanks to polymorphism.Instances of C, therefore, will use
c.foo()(however it is defined), where as instances of A and B will make use ofa.foo()because they have not yet been overridden.