Computer Applications
The output of Math.round(6.6) + Math.ceil(3.4) is:
- 9.0
- 11.0
- 10.0
- 11
Java Math Lib Methods
ICSE Sp 2024
35 Likes
Answer
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.
Answered By
19 Likes
Related Questions
The method of Scanner class used to accept a double value is:
- nextInt()
- nextDouble()
- next()
- nextInteger()
Among the following which is a keyword:
- every
- all
- case
- each
Name the type of error, if any in the following statement:
System.out.print("HELLO")- logical
- no error
- runtime
- syntax
Java statement to access the 5th element of an array is:
- X[4]
- X[5]
- X[3]
- X[0]