Find the output of the following Java
code line:
System.out.println(math.floor(-7.2))
Answers
Answered by
0
Question:
Find the output of the following Java code line:
System.out.println(math.floor(-7.2))
(A) -7
(B) -8
(C) -7.4
(D) -7.0
Answer:
(B) -8 is the correct answer.
Explanation:
Floor function in Java is used to print the lower limit value of the number entered.
As in above example the lower limit of number is -8 and upper limit of number is -7
But, if the number would have been 7.2 then the lower limit would have been 7 and upper limit would have been 8.
On number line we can see this that as we go on towards the positive side of number which is after 0 value keeps on increasing and before 0 value gets decreasing.
That's why the above thing happens.
Similar questions