Sunday, February 25, 2007

Can a Byte object be cast to a double value?

No, an object cannot be cast to a primitive value.


SOURCE : www.referjava.com

1 comment:

lingmaaki said...

No, Java will not implicitly narrow a primitive value. You cannot cast from a double to byte because the byte has a range smaller than the double and it does not contain decimals like a double does. You can explicitly cast it to a Byte via a boxing conversion. This guards against accidental loss of precision.

More..Interview Questions