16. Explain About Floating point declarations ?
Ans:
In Java if you don't specify suffix to floating point value, the compiler assumes 64 bit double value.
To declare a float value suffix with f or F.
float f = 10.0f;
float f = 10.0F;
To declare a double value suffix with d or D.
double d = 10.0d;
double d = 10.0D;
If you declare a float value like following compiler gives error.
float f = 10.0;
Here we are trying to give a floating point 64 double value to a float, which is not correct because floating point literals defaults to a 64 bit double. |