Java Study Notes-14. Object-Oriented Programming 09-differences between reload and rewrite in Java, comparison between super and this

Source: Internet
Author: User

1. Differences between method overloading and method Rewriting

Differences Method overload Method Rewriting
English Words Overloading Override
Concept The method name is the same, and the number or type of parameters are different. The method name is the same, the number and type of parameters are the same, and the access permission of the method cannot be stricter.
Scope of use Occurs in the same class Occurs in the inheritance relationship and is rewritten by the subclass.

2. Comparison between super and this

Comparison Super This
Scope of use Is the content of the parent class accessed by subclass Is to directly access the content in this class
Access attribute format Super. parent class attribute. If the attribute is not rewritten, you can also leave super This. attributes of this class
Access Method format Super. parent class method (). If the parent class method is not rewritten, you can call the method in the parent class without writing super. This. This class method () can be used to call the method of this class without writing this.
Format when accessing the constructor Super () is the constructor used to access the parent class and must be placed in the first line. This () is to access other constructor methods in this class (note that this is the entry !), Must be placed in the first line
Special Points None This indicates the current object. The object of the current operation method is the current object.

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.