Override of method (override overwrite)

Source: Internet
Author: User

1 Rules to override:

1) The "Return value type method name (parameter list)" of the subclass method must be the same as the parent class method

2) The modifier of the subclass method cannot be less than the modifier of the parent class method

3) If the parent method throws an exception, the subclass method throws an exception type that cannot be greater than the parent class

4) The Child parent class method must be either static or non-static

5) The method of private in the parent class cannot be overridden because it is not visible to the child class. You can define the same method name in a subclass, different methods that return a value type, but are not overridden. In addition, other subclass methods that are the same as the parent method name return a value type, and the argument list must be the same.

Override of method (override overwrite)

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.