The difference between overloading (overload) and overriding (override). Can overloaded methods be differentiated according to the return type?

Source: Internet
Author: User

The overloads and overrides of a method are implemented in a polymorphic way, except that the former implements the polymorphism at compile time, while the latter implements the runtime polymorphism. Overloads occur in a class, and methods with the same name are considered overloaded if they have different parameter lists (different parameter types, different number of arguments, or both); Overrides occur between subclasses and parent classes, and overrides require subclasses to be overridden by methods that have the same return type as the parent class, which is better accessed than the overridden method of the parent class. You cannot declare more exceptions than the parent class is overridden by the method (the Richter substitution principle). Overloads do not have special requirements for return types.

The difference between overloading (overload) and overriding (override). Can overloaded methods be differentiated according to the return type?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.