wood burning stoves 2.0*
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Math.random()
 
Similar Threads
Math.random
Error in "final" test on cd for RHE book
RHE question re Math.round() and random()
Math.random() & .round() question from RHE
RHE Final #27