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
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)
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.
4
Q
What is the constructor code-block order?
A
The constructor runs after all fields and instance initializer blocks have run.