What is the result of evaluating the following expression? (1/2 + 3.5) * 2.0
Advertisements
Question
What is the result of evaluating the following expression?
(1/2 + 3.5) * 2.0
Numerical
Advertisements
Solution
(1/2 + 3.5) × 2.0
= (0 + 3.5) × 2.0
= 3.5 × 2.0
= 7.0
In Java, 1/2 performs integer division, giving 0. Therefore, the final result is 7.0.
shaalaa.com
Is there an error in this question or solution?
