This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Math.random() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Math.random()" Watch "Math.random()" New topic
Author

Math.random()

Bill Boyle
Greenhorn

Joined: Aug 10, 2003
Posts: 12
While taking a practice test I ran across this question:
What is the value of the following expression:
Math.round(Math.random() + 2.50001);
A. 2
B. 3
C. It is impossible to say
I thought the answer should be C, but the book said B. Most the time the result should be 3. But is it possible for random() to return .999999
It that case the value would be 4.


Thank you,<br />Bill Boyle
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
You might need to look into this thread.


Mani
Quaerendo Invenietis
Muzammil Khan
Greenhorn

Joined: Jul 22, 2003
Posts: 8
Hi Bill Boyle,
I agree with you the answer should be definetly C. It is impossible to say .


Muzz<br />MSC Computing<br />Nothing worth while will ever be achieved without DEEP THOUGHT AND HARDWORK - J.R.D TATA
 
GeeCON Prague 2014
 
subject: Math.random()