Multiple choice general knowledge

what is the output of this Java program?

  1. Value of float variable f is :12.3

  2. Value of float variable f is :12

  3. error found on the line "float f =12.3;"

  4. none of the above

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

In Java, floating-point literals like 12.3 are treated as double by default (64-bit). To assign them to a float variable (32-bit), you must either use the 'f' suffix (12.3f) or cast the value. Without this, the compiler will flag an error due to potential loss of precision from double to float.