float f = 0.9f;
double d = 0.9;
System.out.println(f == d);
Most of us would think that the output of this code snippet is true but the fact is it will return false due to numeric promotion. If you compare a float value with a double value, the float value will be promoted to double, for this case when f is promoted to double, it will produce 0.8999999761581421. And if you compare this value to 0.9, obviously it will return false.
My question is are there these types of question in the
SCJP exam which I think is sort of confusing? Cause at first glance, IMO, most people will think the answer would be true well in fact, it return false.
Thanks...