Jen Baby Java basic Note inheritance

Source: Internet
Author: User

One, inherit
When some classes have some common content, these common elements can be extracted into the parent class.
1. Analysis of properties and methods common to multiple classes
2. Extract a parent class from the common, create a parent class, and share the same content to the parent class, this class retains only the unique content
3. Subclass inherits parent class using extends

public class subclass name extends parent class name {

}
Super
Call construct: Super (parameter);//put on first line
Call member: Super. Property Super. Method Name ();
In the construction method, super and this cannot be used together

Invocation of a constructor method in an inheritance relationship
The non-parametric construction method of the parent class takes precedence regardless of whether the parent constructor is explicitly called
Properties and methods that do not inherit the private adornment of a parent class

Jen Baby Java basic Note inheritance

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.