当前位置:编程学习 > JSP >>

Overloading and Overriding(English)

答案:Overloading:
Signature has to be different. Just a difference in return type is not enough.Accessibility may vary freely.Exception list may vary freely.Just the name is reused. Methods are independent methods. Resolved at compile-time based on method signature.Can call each other by providing appropriate argument list.

Overriding:
Signature has to be the same. (including the return type)Overriding methods cannot be more private than the overridden methods.Overriding methods may not throw more checked exceptions than the overridden methods.  But can throw no exception.Related directly to sub-classing. Overrides the parent class method. Resolved at run-time based on type of the object.Overriding method can call overridden method by super.methodName(), this can be used only to access the immediate super-class’s method.super.super won’t work. Also, a class outside the inheritance hierarchy can’t use this technique.

 

上一个:XML在各个领域中的运用
下一个:来迟了,人不多:为什么开发人员对XML感到激动

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,