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.

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

How to define a block code?

A

By using curly braces.

{ statements }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
...
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly