Overloading and Overriding(English)

发表于:2007-07-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
Overloading:
Signature has to be different. Just a difference in return type is not enough.Aclearcase/" target="_blank" >ccessibility 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.

 

原文转自:http://www.ltesting.net