Computer Applications
Which of the following mathematical methods returns only an integer?
- Math.ceil(n)
- Math.sqrt(n)
- Math.floor(n)
- Math.round(n)
Java Math Lib Methods
ICSE 2024
5 Likes
Answer
Math.round(n)
Reason — In Java, Math.round(n)
is the only method in the list that returns an integer when called with a floating-point number (float
or double
).
Answered By
4 Likes
Related Questions
Assertion (A): Static method can access static and instance variables.
Reason (R): Static variable can be accessed only by static method.
- Assertion and Reason both are correct.
- Assertion is true and Reason is false.
- Assertion is false and Reason is true.
- Assertion and Reason both are false.
What is the output of the Java code given below?
String color[] = {"Blue", "Red", "Violet"}; System.out.println(color[2].length());
- 6
- 5
- 3
- 2
Write Java expression for:
Evaluate the expression when x is 4:
x += x++ * ++x % 2;