ICSE Class 10 Computer Applications
Question 25 of 76
Revising Basic Java Concepts — Question 29
Back to all questions 29
Question Question 14(m)
State the value and type of each expression.
Math.round(1.49 + 0.1)The output value is 2. The type of expression is long.
Explanation
Math.round() rounds off its argument to the nearest mathematical integer. If argument is float, return type is int, if argument is double, return type is long. In this case, 1.49 + 0.1 = 1.59 so it will be rounded of to 2, the nearest mathematical integer. 1.59 will be treated as double because suffix 'f' is not there. Hence, it will return a value of long data type.