constructor call relationships in Java inheritance

Source: Internet
Author: User

1. If the constructor is not written in the subclass, Java automatically creates a default constructor for the subclass, calling the constructor of the parent class in the constructor, that is, using the Super function to call 2, and if the constructor is indicated in the subclass, you can not write the super function. But the constructor of the parent class is called, but the parameterless constructor of the parent class is now called 3, if the constructor is written in the subclass, you can use the Super function to explicitly call the different constructors of the parent class 4, and in the constructor of the subclass if there is a super function, it must be placed in the first row of the function. And there can only be one 5, subclasses cannot inherit the constructor of the parent class

constructor call relationships in Java 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.