Which statement (exactly one) is true about the following program?
public class Main { public static void main(String[] args) { double d1 = 1.0; double d2 = 0.0; byte b = 1; d1 = d1 / d2;//from w ww . j a v a 2 s . co m b = (byte) d1; System.out.print(b); } }
DivideByZeroException
. D.
Floating-point operations do not throw exceptions.
This eliminates answers A and B.
It would be impossible for a byte value to be displayed as 1.5.
The only answer left is D.