This is legal. float f = 2;
-
Yes
-
No
-
Compile error
-
Don't know
A
Correct answer
Explanation
Java allows implicit narrowing conversion from int literal to float when the value is within float's range. The integer 2 is automatically converted to 2.0f at compile-time, making this statement perfectly legal.