java foundation: the difference between overloading (Overload) and rewritable (Override) is. Overloaded method can be differentiated according to the type of return?

The method of overloading and rewriting are multi-state manner, except that it is implemented compile-time polymorphism, which polymorphism is achieved runtime.

Overload: occur in the same class, the same method name parameter list (different parameter types, different numbers, different sequence), and the method returns a value independent access modifier, i.e. overloaded methods can not be differentiated according to the type of return

Rewriting: occurs in the parent-child class, method name, argument list must be the same, the return value is less than equal to the parent, or less thrown exception parent, the parent class greater than or equal access modifier (Richter substitution principle); if the parent class method access modifier is private is a subclass is not rewritten.

Published 438 original articles · won praise 2 · views 10000 +

Guess you like

Origin blog.csdn.net/qq_37769323/article/details/104603163