Advertisements
Advertisements
Question
Which of the following is implicit typecasting?
Options
int p = (int) 49.8 + 26;long m = (int) 49.8*2;double d = 49.8 + 56;double b = 38/10;
MCQ
Advertisements
Solution
double d = 49.8 + 56;
Explanation:
In this statement, you are adding a decimal double (49.8) to a whole number int (56). Java automatically converts the smaller integer type into a double type (56.0) during runtime so it can perform the math smoothly without any manual syntax or data loss.
shaalaa.com
Is there an error in this question or solution?
Chapter 2: Class as the Basis of all Computation - Exercises [Page 64]
