Computer Science
What are the resulting data types, if the following implicit conversions are performed:
int i; float f; double d; char c; byte b;
(a) i + c/b;
(b) f/d + c*f;
(c) i + f - b*c;
(d) i/c + f/b;
(e) i + f- c + b/d;
Values & Data Types Java
7 Likes
Answer
(a) i + c/b;
i + c/b;
⇒ int + char / byte
⇒ int + char
⇒ int
(b) f/d + c*f;
f/d + c*f;
⇒ float / double + char * float
⇒ double + float
⇒ double
(c) i + f - b*c;
i + f - b*c;
⇒ int + float - byte * char
⇒ int + float - char
⇒ float - char
⇒ float
(d) i/c + f/b;
i/c + f/b
⇒ int / char + float / byte
⇒ int + float
⇒ float
(e) i + f- c + b/d;
i + f- c + b/d;
⇒ int + float - char + byte / double
⇒ int + float - char + double
⇒ float - char + double
⇒ float + double
⇒ double
Answered By
5 Likes
Related Questions
Perform the following:
Assign the value "TEST" to a variable with the requisite data type.
Predict the return data type in the following expressions:
int p; double q;
r = p+q;Predict the return data type in the following expressions:
float m;
p = m/3*(Math.pow(4,3));What are the resulting data types of the following explicit conversions?
int i; float f; double d; short s; char c; byte b;
(a) (float) i/b + d;
(b) (int)f*d + c/s;
(c) (char)i + f - b*d;
(d) (double) (f/i)*c + s;
(e) (char) d + b/i - f*s;