Multiple choice

Which method provides random value in java?

  1. Math.random();

  2. getRandom();

  3. setRandom

  4. random();

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Math.random() is the standard Java method that returns a double between 0.0 and 1.0. Option B (getRandom) doesn't exist in Java API. Option C (setRandom) is not a standard method. Option D (random) alone isn't valid without Math. prefix.