The difference between Overload and Override
Overload means that there can be multiple methods with the same name in the same class, but the parameter lists of these methods are different, that is, the parameters The parameters or parameter types are different. Of course, the return value can be different during overloading, but if the parameter list is completely consistent, overloading cannot be achieved through inconsistent return types. This is not allowed.
Override means that the method in the subclass can have the same name and parameters as the method in the parent class. When this method is called through an object created by the subclass, the method defined in the subclass will be called, that is, It is the method in the subclass that overrides the method in the parent class. When a subclass overrides a parent class method, it can only throw fewer or smaller exceptions than the parent class. The return of the overridden method must be consistent with the return of the overridden method.
The basic data types of Java are divided into: 1. Integer type, used to represent the data type of integer. 2. Floating point type, a data type used to represent decimals. 3. Character type. The keyword of character type is "char". 4. Boolean type is the basic data type that represents logical values.
The above is the detailed content of What is the difference between Overload and Override in java. For more information, please follow other related articles on the PHP Chinese website!