Java OCA OCP Practice Question 1618

Question

In which of these variable declarations will the variable remain uninitialized unless it is explicitly initialized?.

Select the one correct answer.

  • (a) Declaration of an instance variable of type int.
  • (b) Declaration of a static variable of type float.
  • (c) Declaration of a local variable of type float.
  • (d) Declaration of a static variable of type Object.
  • (e) Declaration of an instance variable of type int[].


(c)

Note

The local variable of type float will remain uninitialized.

Fields and static variables are initialized with a default value.

Local variables remain uninitialized unless explicitly initialized.

The type of the variable does not affect whether a variable is initialized or not.




PreviousNext

Related