Advertisements
Advertisements
Question
Given: double k = Math.rint(−9.4) + Math.sqrt(9.0);
Options
−5.0
−6.0
−6.4
−5.4
MCQ
Solution
−6.0
Explanation:
Math.rint(−9.4) will return −9.0, which is the nearest integer to −9.4. Math.sqrt(9.0) yields 3.0. Therefore, the expression is solved as follows:
k = Math.rint(−9.4) + Math.sqrt(9.0);
k = −9.0 + 3.0
k = −6.0
shaalaa.com
Is there an error in this question or solution?