OCA Java SE 8 Building Blocks - OCA Mock Question Building Block 7
Question
Which of the following are true? (Choose all that apply)
- An instance variable of type int defaults to null.
- An instance variable of type double defaults to null.
- An instance variable of type String defaults to null.
- An instance variable of type double defaults to 0.0.
- An instance variable of type String defaults to 0.0.
- An instance variable of type int defaults to 0.0.
- None of the above.
Answer
Note
C is correct since all non-primitive values default to null.
D is correct because float and double primitives default to 0.0.
int primitives default to 0.
String defaults to null.