OutputModerate2 marks
Give the output of the following: (i) Math.pow(36, 0.5) + Math.cbrt(125) (ii) Math.ceil(4.2) + Math.floor(7.9)
Topic: Math class methods
Previous-year question practice database
Answer
Exam answer
(i) 11.0 (ii) 12.0
Explanation
(i) Raising to the power 0.5 is the same as taking the square root, so Math.pow(36, 0.5) is 6.0. Math.cbrt(125) is the cube root, 5.0. Their sum is 11.0. (ii) Math.ceil() always rounds UP, so 4.2 becomes 5.0. Math.floor() always rounds DOWN, so 7.9 becomes 7.0. Their sum is 12.0. Note that floor() ignores how close 7.9 is to 8 — it never rounds to nearest. In both parts the answer must carry the decimal point, since all four methods return doubles. Writing 11 and 12 loses the mark.
More from Library Classes
What is the output of the statement Math.pow(36, 6/5);?2026The output of the statement:
System.out.println(Character.toUpperCase('b') + 2); is:2026What is the type of parameter to be given for the method parseInt()?2026Write the Java expression to find the sum of cube root of x and the absolute value of y.2026Character class methods are found in the package called:2025The output of Math.max(-7, Math.min(-5, -4)) is2025