What happened behind new deerivedclass () in java

xiaoxiao2021-03-06  25

What happened behind new deerivedclass () in java

(Original - Shao Zhengjun, 2005-4-5)

Class DerivedClass Extends Baseclass {...}

New derivedclass ();

1 Loading CLASS

1.1 Load BaseClass where [Load Class] is generated here.

1.2 Load DerivedClass

1.2.1 is a class scope variable, that is, the static variable, allocated storage space, and assigns a default value.

1.2.2 Calling , including: a). Statement class scope variables and assigning statements b). The assignment statement included in Static {...} and any other legitimate statement .c). To illustrate : The right value of the above assignment statement can also be a function call, which is legal.

2 Allocate storage space for example scope variables and assign default.

3 call constructor *** Note: Java specifies: The first barrier of constructor must be a call to the Super constructor. If this is not the case, it will be automatically sneaked by the compiler.

3.1 Call the SUPER constructor where [Call Construction Function] is generated here.

3.2 Calling , including: a). Declare an instance scope variable, the instance variable, and assign the statement B). Contains the assignment statement in {...} with the Method set and any other legal perspective. c). To explain: The right value of the above assignment statement can also be a function call, that is legal.

3.3 Performing the remainder in the constructor.

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

New Post(0)