Method overloading (Overroad) and method override (override)------Java Basics Summary

Source: Internet
Author: User

A, what is method overloading? (in the same Class) method overloading refers to the case where the same method name appears in the same class, with a different argument list.
B, what is method coverage? A method override in a child-parent class is a function that runs a subclass when a method declaration is identical to the parent class, which is called a overwrite operation.
Method overrides occur between the parent class and the subclass with the inheritance relationship, and after the subclass inherits the method of the parent class, it is found that the method implementation is not enough to meet the requirements of the next generation, so it gives a new method implementation.
Coverage considerations:

    • When a subclass method overrides a parent class method, the child class permission must be greater than or equal to the permission in the parent class.
    • Static can only be overridden statically or statically.

C, how to determine whether the method is overloaded?

      • Method names must be the same
      • The return value type may be different
      • The parameter list must be different: The parameter types are different, the number of parameters is different, the parameter order is different.

Method overloading (Overroad) and method override (override)------Java Basics Summary

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.