[HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

[HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by flex567 »

Is there a complete list of order of initalization for a class in this book?
I think it is something like this:
The order of initialization of a class is:
1. All static constants, variables and blocks.(Among themselves the order is the order in which they appear in the code.)
2. All non static constants, variables and blocks.(Among themselves the order is the order in which they appear in the code.)
3. Constructor.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by admin »

Actually, Section 9.3.1 discusses the object initialization (i.e. order of initialization of an object of a class) and not class initialization. The two are different. Class initialization happens only the first time that a class is used and not every time that an object of that class is created.

Class initialization is discussed in Section 8.3.6.

Based on your query, I have requested the author to improve this section by including the situation where a class has a superclass as well.

thank you for your feedback!
Paul.
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by flex567 »

There sould be one example with static initializer and instance initializer together. Since questions like that are frequent in exercise.

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by admin »

Section 9.3.4 has now been added to summarize all the steps with an example. Thank you for your feedback!
If you like our products and services, please help us by posting your review here.

flex567
Posts: 202
Joined: Mon Apr 02, 2018 8:40 am
Contact:

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by flex567 »

Is there a way for me to those changes?

admin
Site Admin
Posts: 10036
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: [HD Pg 0, Sec. 9.3.1 - object-initialization-revisited]

Post by admin »

Please check your PM.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 48 guests