Java OCA OCP Practice Question 196

Question

Which type can fill in the blank?

pi = 3.14; 
  • A. byte
  • B. float
  • C. double
  • D. short


C.

Note

Options A and D are incorrect because byte and short do not store values with decimal points.

Option B is tempting.

3.14 is automatically a double.

It requires casting to float or writing 3.14f in order to be assigned to a float.

Therefore, Option C is correct.




PreviousNext

Related