I am asking this here because I really don't know how I should Google this. I need a confirmation of something that I probably figured out today. Some days ago I thought that if an object inherits a method of its father it means that it basically "has" the method in its code. But then I asked what if we do this:
class B extends A {
public B() {
}
public int getValue() {
return 2 * super.getValue();
}
}
class C extends B {
public C() {
}
public int getValue(int b) {
return 5 * b;
}
}
And lets say there is a class A that has the getValue()
method too. Now an object of class C uses "its" getValue()
method (without parameter) that it has inherited from B.
But super.getValue()
still refers to class A, even though the method calling it was inherited.
Inheritance does not mean that class C "has" the method in its code, but that it can use it from B, right? super()
still refers to the superclass of its "original" class.
Is that insight correct?