File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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


Bill Boyle

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.

Quaerendo Invenietis
Muzammil Khan

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:
subject: Math.random()
It's not a secret anymore!