System.out.println(Math.rint(-9.4)+Math.sqrt(9.0); With explanation
Answers
The answer is -6.0 because math.rint Will return -9.0 and math.sqrt will return 3.0 and it will be in double type
System.out.println(Math.rint(-9.4)+Math.sqrt(9.0); Output: -6
The above code is from the Java language.
Math.rint() method of Java rounds off the value in the argument to the nearest integer.
Syntax: Math.rint(argument);
Example: Math.rint(23.75);
Output: 24
In the given code, -9.4 is a floating-point value.
Math.rint(-9.4) will return -9.0.
Math.sqrt() method of Java returns the square root of the value entered in the argument.
Syntax: Math.sqrt(argument);
Example: Math.sqrt(25.0);
Output: 5.0
In the given code, 9.0 is a double value.
Math.sqrt(9.0) will return the square root of 9.0. 3.0 is the square root of 9.0.
Now, Math.rint(-9.4)+Math.sqrt(9.0) will add the values of Math.rint(-9.4) and Math.sqrt(9.0).
-9.0 + 3.0 = -6.0
System.out.println() prints the argument passed inside it in the new line.
Therefore, the output of the following code is -6.0.
#SPJ3