Method overloading and overriding differences, method overloading overrides the difference
Answer one: Fundamental differences:
Rewrite (refactoring) is very intuitive ah, the child class overrides the parent class with the same name as the return value of the method, called by the subclass is only the overridden method
Overloaded with the same name. Answer two: 1. Overloading:
Method name is the same, parameter list is different
2. Rewrite:
Also called overwrite, which defines a method in a subclass that has the same name as the argument list of a method in the parent class. Because subclasses inherit the methods of the parent class, overriding is redefining the method inherited from the parent class and re-filling the code in the method.
Answer three:
Overriding is a method of a subclass that overrides a method of the parent class, requiring the method name and parameters to be the same
Overloading is two or more than two methods in the same class, with the same method name, but the parameters are not the same, the method body is not the same, the most common example of overloading is the constructor of the class, you can refer to the API Help document to see the construction method of the class
Answer four:
1. Overrides must be inherited, not overloaded.
2. The overridden method name, the same number of parameters, the parameter type is compatible, the overloaded method name is the same, the parameter list is different.
3. The overridden method modifier is greater than or equal to the parent class's method, overloaded and modifier independent.
4. Overrides can not throw generic exceptions that are not thrown by the parent class, and can throw runtime exceptions
http://www.bkjia.com/PHPjc/1122389.html www.bkjia.com true http://www.bkjia.com/PHPjc/1122389.html techarticle Method overloading and overriding differences, method overloading override difference answer one: The fundamental difference: rewrite (refactoring) is very intuitive ah, the child class overrides the parent class with the same parameter as the return value of the method, with the child ...