English

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?
Chapter 6: Variables and Expressions - EXERCISE [Page 133]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 6 Variables and Expressions
EXERCISE | Q 49. | Page 133
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×