
Java Random Number Generation Quiz
Authored by Patrick Bryar
Computers
12th Grade

AI Actions
Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...
Content View
Student View
10 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What method is used in Java to generate a random number between 0.0 (inclusive) and 1.0 (exclusive)?
Math.randomInt()
Random.nextInt()
Random.generate()
Math.random()
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following formulas can be used to generate a random integer between 0 and 100 in Java?
int randomNum = (int)(Math.random() * 101);
int randomNum = (int)(Math.random() * 100);
int randomNum = Math.random() * 100;
int randomNum = Random.nextInt(100);
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the return type of the Math.random() method in Java?
int
double
float
long
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the range of values returned by Math.random() in Java?
0.0 (inclusive) to 1.0 (exclusive)
0.0 (exclusive) to 1.0 (exclusive)
0.0 (inclusive) to 1.0 (inclusive)
0.0 (exclusive) to 1.0 (inclusive)
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
To generate a random integer between 1 and 10, which of the following expressions is correct?
int randomNum = (int)(Math.random() * 10) + 1;
int randomNum = Math.random() * 10 + 1;
int randomNum = (int)(Math.random() * 11);
int randomNum = Random.nextInt(10) + 1;
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of casting in the expression (int)(Math.random() * 101)?
To generate a floating-point number
To ensure the result is always positive
To increase the range of random numbers
To convert the double result to an integer
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following is a correct way to generate a random number between 0 and 50?
int randomNum = (int)(Math.random() * 50);
int randomNum = Math.random() * 50;
int randomNum = (int)(Math.random() * 51);
int randomNum = Random.nextInt(50);
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
python quiz
Quiz
•
6th Grade - Professio...
10 questions
Java: repetition control structure for & while
Quiz
•
10th - 12th Grade
12 questions
тест Python 7 class
Quiz
•
1st - 12th Grade
12 questions
Session 2 - Hardware and Peripherals
Quiz
•
10th Grade - University
15 questions
Empowerment Technologies
Quiz
•
KG - 12th Grade
15 questions
Basics in Java
Quiz
•
9th - 12th Grade
11 questions
PSP/IT test 2
Quiz
•
12th Grade
10 questions
Computer Languages
Quiz
•
6th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
20 questions
Figurative Language Review
Quiz
•
6th Grade