created 08/04/07; small changes 10/17/2012


quiz Quiz on Random

Instructions: For each question, choose the single best answer. Make your choice by clicking on its button. You can change your answers at any time. When the quiz is graded, the correct answers will appear in the box after each question.


1. When a source of random numbers produces each number in its range equally often, the distribution of numbers is said to be ___________ ?

A.    Uniform

B.    Uninformed

C.    Level

D.    Equal


2. What are pseudorandom numbers, such as those Random generates?

A.    Pseudorandom numbers are random numbers with several extra characteristics.

B.    Pseudorandom numbers are random numbers that follow a uniform distribution.

C.    Pseudorandom numbers are less predictable than truely random numbers.

D.    Pseudorandom numbers look like random numbers in most applications, but are generated by an algorithm and are completely predictable if you know the seed.


3. What is the seed of a pseudorandom number generator?

A.    The seed provides a name for the random number generator.

B.    The seed initializes the stream of pseudorandom numbers that the generator produces.

C.    The seed determines the range of values that the generator produces.

D.    The seed determines how many random numbers will be generated.


4. Assume that a random number generator has been constructed with Random rand = Random(); Which of the following randomly selects an integer from the range 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 ?

A.    rand.nextInt(9)

B.    rand.nextInt()*10

C.    rand.nextInt(1,10)

D.    rand.nextInt(10)


5. Assume that a random number generator has been constructed with Random rand = Random(); Which of the following randomly selects an integer from the range 10, 11, 12, 13, 14, 15?

A.    rand.nextInt(5)

B.    rand.nextInt(6) + 10

C.    rand.nextInt(10,15)

D.    rand.nextInt(5) + 9


6. What range of values is generated by nextInt()?

A.    All positive integers.

B.    All possible int values, negative, zero, and positive.

C.    Integers from 1 to 100

D.    Integers from 0 to 99


7. When a new object is constructed using new Random(), what is the seed based on?

A.    A random seed selected by the system.

B.    A default seed value.

C.    The current time in milliseconds.

D.    The same seed as was used previously.


8. What range of values is output by nextDouble()?

A.    All double precision floating point values, negative and positive.

B.    All positive double precision floating point values.

C.    Double precision floating point values from -1.0 to 1.0.

D.    Double precision floating point values from 0.0 to slightly less than 1.0.


9. Which of the following selects random floats in the range -10.0 up to but not including 15.5? Assume that rand is a Random object.

A.    rand.nextDouble(-10,15.5)

B.    25.5*rand.nextDouble() - 10.0

C.    15.5*rand.nextDouble() - 10.0

D.    rand.nextDouble(15.5) - 10.0


10. A teacher wishes wants a random selection A, B, C, D, E for the answers to a multiple-choice test. Which of the following can be used?

A.   

Random rand = new Random(); 
. . .
char answer  =  "ABCDE".charAt( rand.nextInt() );

B.   

Random rand = new Random(); 
. . .
char answer  =  "ABCDE".charAt( rand.nextInt(6) );

C.   

Random rand = new Random(); 
. . .
char answer  =  "ABCDE".charAt( rand.nextInt(5) );

D.   

Random rand = new Random(); 
. . .
char answer  =  "ABCDE".rand.nextInt(4) ;


The number you got right:       Percent Correct:       Letter Grade:   


Click here If you have returned here from another page, or have re-loaded this page, you will need to click again on each of your choices for the grading program to work correctly. You may want to press the SHIFT KEY while clicking to clear the old answers.