ICSE Class 10 Computer Applications
Question 47 of 76
Revising Basic Java Concepts — Question 51
Back to all questions 51
Question Question 30(c)
Give the output of the following :
- Math.floor(-4.7)
- Math.ceil(3.4) + Math.pow(2,3)
(1) Math.floor(-4.7)
Output
-5.0
Explanation
Math.floor method returns the largest double value that is less than or equal to the argument and is equal to a mathematical integer. As -5.0 is the largest mathematical integer less than -4.7 so it is the output. Note that -4.7 is a negative number so the largest integer less than -4.7 is -5.0 and not -4.0.
(2) Math.ceil(3.4) + Math.pow(2,3)
Output
12.0
Explanation
Math.ceil(x) function returns the smallest whole number greater than or equal to x. Math.ceil(3.4) gives 4.0 and Math.pow(2,3) gives 8.0. So the output is 4.0 + 8.0 = 12.0.