RSS
热门关键字:
当前位置 : 主页>编程开发>Jsp教程>列表

Overloading and Overriding(English)

来源:我要研发网 作者: 时间:1970-01-01 点击:



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.

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册
相关文章