Texture function problem in Java class inheritance

xiaoxiao2021-03-06  40

We assume that A is the parent class of B, B is a subclass of A. 1. If the programmer does not provide a constructor to class A, the compiler will automatically provide a default parameter constructor. If the user provides its own constructor, the compiler is not providing the default parameter constructor. . 2, the subclass B instantiates automatically call the default constructor of the parent class A, so if the default non-parametric constructor of A is Private, the compiler will report an error, and if A does not provide the default non-parametric configuration Functions, provide other types of constructor, the compiler will also report an error because B can not find a default non-parameter constructor. So, we best give the parent class A to provide a parameter-free constructor.

转载请注明原文地址:https://www.9cbs.com/read-78347.html

New Post(0)