• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Seed Value

 
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From web page


What is the seed value?
 
Ranch Hand
Posts: 10198
3
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say the answer is d.
 
Micheal John
Ranch Hand
Posts: 344
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
But answer is e.None of the above..
And also I want to know what is seed value?
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@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.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Barry Gaunt posted December 08, 2006 05:03 AM

@Bu: just go up in the directory and down into this


thanks, found it.
Bu.
 
Hang a left on main. Then read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic