*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Seed Value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Seed Value" Watch "Seed Value" New topic
Author

Seed Value

Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
From web page


What is the seed value?


Micheal John
SCJP 1.4 (86%), SCWCD 1.4 (86%), SCBCD 1.3 (85%), SCDJWS (Just Started...) - Satisfaction Lies in Our EFFORT, Not in the ATTAINMENT
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9345
    
    2

I'd say the answer is d.


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Micheal John
Ranch Hand

Joined: Nov 01, 2006
Posts: 344
But answer is e.None of the above..
And also I want to know what is seed value?
Bin Qian
Greenhorn

Joined: Sep 13, 2006
Posts: 18
I think the answer is e.
because the random method is a static method.so it cann't be overloaded.and it has no argument, and the returned value is greater or equals to 0 and always less than 1.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
The question is very simply answered if you look at the Java API for Math.random. There you will see that there is only one double Math.random() method. So you do not even have to know for this question what a seed value is.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Of course, you can always read Dan's own answers. He put a lot of effort into his questions and explanations, so spend time reading them, you can learn a lot.
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi ranchers,

I could not find the solution page in the link provided from Michael (question #12).

Anyway, a seed is a starting value in generating pseudo random numbers.
If you specify the seed, all "random" numbers generated from this will appear in the same sequence.

But in Math.random() you cannot specify the seed, it is calculated from the system time in milliseconds.

You can however specify the seed in the java.util.Random class.
Example:

The first two columns started with the same seed show the same "random" numbers.
Output is



Seed is used when you want some control in your random numbers, eg when doing statistics or cheating in online poker games. For the last thing be sure your gun is faster, cowboys.


Yours,
Bu.


all events occur in real time
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
@Bu: just go up in the directory and down into this

As I said before knowing what a seed is to 100% irrelevant to this question. Looking at the Math API is the important thing to learn to do.
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8805
    
    5
from the wet towel dept.:

This is clearly NOT a SCJP 5 topic and I think it's a little outside the scope of the 1.4 exam too.


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Barry Gaunt posted December 08, 2006 05:03 AM
@Bu: just go up in the directory and down into this

thanks, found it.
Bu.
 
Consider Paul's rocket mass heater.
 
subject: Seed Value
 
Similar Threads
Class Random or Math.random()???
Random question
Random collisions
java.util.Random setSeed() and biwise operators
A thorny problem about class Random