Features of the JAVA sub-parent class and java features

Source: Internet
Author: User

Features of the JAVA sub-parent class and java features

I. variables (attributes)
This indicates the reference of the current object. this variable is first found in this class. If it is not found, it will be found in the parent class.
Super is used to access the current object's parent class member super. The variable is directly located in the parent class

Ii. Functions (methods)
When the same function in the parent class appears in the subclass, when the subclass object calls this function,
It runs a function in the subclass, just as the function in the parent class is overwritten,
This is another feature of the function: rewrite (overwrite)

Note:
1. When a subclass member overwrites a parent class member, you must ensure that the permission of the subclass is greater than or equal to that of the parent class. Otherwise, the compilation fails.
Access permission modifier: the default private member of the public default does not have any access permission modifier before the default permission is defalut.
2. Static only covers static
Remember:
Overload: view the parameter list of methods with the same name.
Rewrite: the sub-parent class methods should be identical

Iii. Constructor (constructor)

When a subclass is created, the constructor of the subclass is called and the constructor of the parent class is automatically called.

The syntax for manually calling the parent class constructor is: super ();

The syntax for manually calling the current class constructor is: this ();

The two syntaxes can contain parameters or no parameters.

 

Word: super means "super"

Related Article

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.