1

如果一个方法被重载,它是否仍然从父类继承原始方法?超载呢?它还会继承原来的加上被覆盖的吗?

4

3 回答 3

5

如果一个方法被重载,它是否仍然从父类继承原始方法?

是的,您可以同时使用它们。

超载呢?它还会继承原来的加上被覆盖的吗?

再次 - 是的,但在这种情况下,要访问原始方法,您必须使用 call super.originalMethod()

于 2012-11-28T13:16:22.093 回答
1

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.

于 2012-11-28T13:17:19.667 回答
0

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().

于 2012-11-28T13:16:57.940 回答