//one.java
class output
{
public static void main( String args[])
{
float a=43.80;
System.out.println(a);
}
}
A)
In the above program there is Syntactical error. If we use a decimal literal in a java application (here it is “43.80”), java compiler thread by default as double type. Therefore “loss of precision “error is reported.
-> to fix the problem we have to append “ f ”/” F ” to the decimal literal to indicate that it is a single precision literal. Or change the data type as “double”. F float a=43.80f; or float a=43.80f;
Or double a=43.80;
Note: byte , short , int and long represent numerical integer (non decimal) data types.
Comments
Post a Comment