Home » Java Programming » Objects and Collections

Which is valid declaration of a float?

Correct Answer: float f = 1F;

Explanation:

Option A is valid declaration of float.


Option B is incorrect because any literal number with a decimal point u declare the computer will implicitly cast to double unless you include "F or f"


Option C is incorrect because it is a String.


Option D is incorrect because "d" tells the computer it is a double so therefore you are trying to put a double value into a float variable i.e there might be a loss of precision.


← Previous Question Next Question→

More Questions from Objects and Collections

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion