1(viii)
The output of Math.round(6.6) + Math.ceil(3.4) is:
- (a)9.0
- (b)11.0
- (c)10.0
- (d)11
Show SolutionHide Solution↓
11.0
Reason — The given expression is evaluated as follows:
Math.round(6.6) + Math.ceil(3.4)
⇒ 7 + 4.0
⇒ 11.0
Math.round() rounds off its argument to the nearest mathematical integer and returns its value as an int or long type. Math.ceil method returns the smallest double value that is greater than or equal to the argument and is equal to a mathematical integer. In the addition operation, the type of result is promoted to a double as one operand is double. Hence, the result is 11.0.