Hi rehan.You are right in stating that a floating point value by default is interpreted as a double in Java.Let's go through the code..
The expression
cannot be evaluated at compile time.
Division will be performed at runtime,and 0.333...3 will be obtained,which will be a double value.But this value is being stored in a variable of type float,and this results in loss of precision.Now float f will have value 0.0.
Same is the case for int
But the expression
can evaluated at compile time ,since 1.01 is a compile time constant.Here the compiler evaluates 1.01 to a double value,and as such throws an Exception.
I hope that helps.
------------------
Udayan Naik
Sun Certified
Java 2 Programmer