in Java
3,790 views
7 votes
7 votes

Find the output of the following Java code line 

System.out.printIn(math.floor(-7.4))
  1. -7
  2. -8
  3. -7.4
  4. -7.0
in Java
3.8k views

3 Comments

For floor function

We can write -7.4 as -7.0  only know

Can u pls say how it will be -8
1
1

Floor is a function in java which returns the lower limit. Here -8 is lower limit to -7.4 and the higher limit would be -7.

If you represent these numbers on the number line you would have -7 approaching towards zero and -8 away from 7.4 and far from zero so the lower limit would be -8.

Hence the answer is -8.

3
3
Friends (like me :( ) who thought $-7$ would be the answer made a simple mistake.

Floor function returns the smaller value. The negative the number the smaller the value. Thus floor(-7.4) will be $-8$ and not $-7$
0
0

2 Answers

11 votes
11 votes
Best answer

Ans B) -8

floor is lower limit

selected by
2 votes
2 votes
 floor method​  of Java Math class. floor method returns the largest interger .so answer is (b)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true