Computer Applications
State the value and type of each expression.
Math.round(3.499)
Java Math Lib Methods
10 Likes
Answer
The output value is 3. 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, 3.499 will be treated as double because suffix 'f' is not there. Hence, it will return a value of long data type.
Answered By
3 Likes