Predict the return data types of the following:
(i) int p; double q;
r = p + q;
System.out.println(r);
(ii) float m;
p = m/3*(Math.pow(4,3));
System.out.println(p);
Attachments:
Answers
Answered by
4
Answer:
1) double and 2) error
Explanation:
1) the compiler will implicitly convert int to double
2) Math.pow() function returns a double and float + double is a double but since p is an int the compiler will return an exception "possible loss of precision".
Similar questions