Computer Applications
What are the resultant data types if the following implicit conversions are performed? Show the result with flow lines.
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) (f/i)*c + b;
(e) i + f- c + b/d;
(f) i/c + f/b;
Values & Data Types Java
256 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) (f/i)*c + b;
(f/i)*c + b;
⇒ (float / int) * char + byte
⇒ float * char + byte
⇒ float + byte
⇒ 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
(f) i/c + f/b;
i/c + f/b
⇒ int / char + float / byte
⇒ int + float
⇒ float
Answered By
158 Likes
Related Questions
In what way is static declaration different from dynamic declaration?
What do you mean by non-primitive data type? Give examples.
Predict the return data type of the following:
int p; double q; r = p+q; System.out.println(r);Predict the return data type of the following:
float m; p = m/3*(Math.pow(4,3)); System.out.println(p);