Assume the following declarations: short a=12; int b=33; float x=2.3; double y=3.14; Which one of the following expressions will NOT be evaluated using double precision floating point?
Advertisements
Question
Assume the following declarations:
short a=12;
int b=33;
float x=2.3;
double y=3.14;
Which one of the following expressions will NOT be evaluated using double precision floating point?
Options
a + x
1.5 + 8.6
a + b
x/y
MCQ
Advertisements
Solution
a + b
Explanation:
Both a (short) and b (int) are integer data types. In Java, the short value is promoted to int, so the expression a + b is evaluated using integer arithmetic, not double-precision floating-point arithmetic.
shaalaa.com
Is there an error in this question or solution?
