如果一个方法被重载,它是否仍然从父类继承原始方法?超载呢?它还会继承原来的加上被覆盖的吗?
3 回答
如果一个方法被重载,它是否仍然从父类继承原始方法?
是的,您可以同时使用它们。
超载呢?它还会继承原来的加上被覆盖的吗?
再次 - 是的,但在这种情况下,要访问原始方法,您必须使用 call super.originalMethod()
。
if a method is overloaded, does it still inherit the original method from the parent class?
yes.
What about overriding?
yes, but the overidden method is not accessible to other classes.
Would it also inherit the original plus the overridden one?
yes.
In case of overloading, the method in the parent class is still available in the child class.
In case of overriding, the method doesn't run the parent's version unless explicitly called using super.method()
.