2.3_Following Order of Initialization Flashcards

1
Q

What is the order of execution for initialization code- blocks?

A

o Object Fields declaration and inline-initialization (Regardless of its location)
o Instance Initializer blocks in the order they appear
o Constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Can we refer to a variable from a initializer block before it has been declared?

A

Yes, initializer blocks run after defining the object fields (structure)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the instance initializer code-block order?

A

From top to bottom.

Instance Initializer Blocks are run in the order in which they appear in the file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the constructor code-block order?

A

The constructor runs after all fields and instance initializer blocks have run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly