2.2_Executing Instance Initializer Blocks Flashcards
1
Q
What are Java code blocks?
A
Block of code in Java allows grouping of two or more statements.
2
Q
How to define a block code?
A
By using curly braces.
{ statements }
3
Q
What blocks of code are defined within Java?
A
o Class declaration/definition o Instance o Method declaration/definition o Initializers o Inner blocks ...
4
Q
What could cause a compilation error when defining a block code?
A
o Unbalanced curly braces
o Don’t finish properly its statements with a semi-colon
5
Q
Difference between instance initializers and inner blocks?
A
- > initializers are declared outside any method but defined within a class definition.
- > inner blocks are block-codes defined within a method aka. “fields initializers”