ExamVeda
Login
Home
Constructors and Methods
?

Determine output of the following program.
public class Test{
           public static void main(String args[]){
                  System.out.println( Math.floor( Math.random( ) ) ) ;
           }
}

Answer & Solution
Correct Answer: Option C

random() is a static method defined in Math class.
Syntax: static double random()
random() always return a value in the range 0.0 <= Math.random() <1.0 So, taking floor function of any number between above range always yield 0.0.
Ex: Math.floor(0.958127101241...) = 0.0

    Math.floor(0.05684865565...) = 0.0
Examveda
Question posted by Examveda
Community

Join the Discussion

No comments yet Be the first to discuss this question.