+ 1
Why does this problem print 12.0?
int x, y; double z; x = 5; y = x * 2; z = x / 2 + y; System.out.print(z);
4 Réponses
+ 5
integer/integer will result in an integer in Java, decimal part will be removed(no rounding off).
+ 5
x=5;
y=x*2;//10
z=x/2+y//2+10
Because x is a int variable then its return int value
z=12.0
Because z is a double variable and its store double value using type casting
0
Because 12 is double although not containing decimals but show decimal part
0
InvBoy [ :: FEDE :: ] 12.5 ???!!!



