OCA Java SE 8 Building Blocks - OCA Mock Question Building Block 11








Question

Which of the following are true? (Choose all that apply)

  1. An instance variable of type boolean defaults to false.
  2. An instance variable of type boolean defaults to true.
  3. An instance variable of type boolean defaults to null.
  4. An instance variable of type int defaults to 0.
  5. An instance variable of type int defaults to 0.0.
  6. An instance variable of type int defaults to null.
  7. None of the above.




Answer



A, D.

Note

A and D are correct because boolean primitives default to false and int primitives default to 0.

String defaults to null.

double and float defaults to 0.0.

int, short, byte and long all default to 0.