Java Programming - Java.lang Class - Discussion

1. 

Which statement is true given the following?

Double d = Math.random();

[A]. 0.0 < d <= 1.0
[B]. 0.0 <= d < 1.0
[C]. Compilation fail
[D]. Cannot say.

Answer: Option B

Explanation:

The Math.random() method returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0


N@W@Z said: (Jul 23, 2015)  
In that above statement it should be:

double d = Math.random.

Keyword must be in small case that is why compilation error occurs.

Niriksha said: (Jun 20, 2016)  
What are the default ranges for all datatypes?

Can any one answer this?

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.