Advertisements
Advertisements
Question
Identify the incorrect statement.
Options
long g = 65.8;int t = 72;byte b = 3;double h = 92;
MCQ
Advertisements
Solution
long g = 65.8;
Explanation:
Tries to assign a decimal value (which Java treats as a float) to a long integer variable. Because a long can only store whole numbers, this causes a compile-time type mismatch error due to a loss of precision.
shaalaa.com
Is there an error in this question or solution?
Chapter 2: Class as the Basis of all Computation - Exercises [Page 64]
