Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the difference between Overload and Override in java

Shulou Source: shulou.com Published: 2022-06-01 03:46:12 11月07日 Update

This article mainly shows you "what is the difference between Overload and Override in java". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what is the difference between Overload and Override in java".

The difference between Overload and Override

Overloaded Overload means that there can be multiple methods with the same name in the same class, but these methods have different parameter lists, that is, different parameter parameters or parameter types. Of course, the return values can be different when overloaded, but if the parameter list is exactly the same, you cannot overload through inconsistent return types, which is not allowed.

Overriding Override means that the method in the subclass can have exactly 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 is called, that is, the method in the subclass overrides the method of the parent class. When a subclass overrides a parent method, it can only throw fewer or smaller exceptions than the parent class. The return of the overridden method must be consistent with that of the overridden method.

What are the basic data types of java? the basic data types of Java can be divided into: 1. Integer types, which are used to represent the data types of integers. 2. Floating point type, which is used to represent the data type of decimals. 3. Character type. The keyword of character type is "char". 4. Boolean type, which is the basic data type that represents logical values.

The above is all the content of the article "what's the difference between Overload and Override in java". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Type method parameter subclass data consistency content article different same name character that is integer learning help key keyword multiple object Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Linux MySQL MariaDB Apple