Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
medium Solved by 6 students

Generating Random Integers in a Range

< Prev
Next >

Which of the following Java statements correctly generates a random integer in the range from -23 to 8, inclusive?

A

int rand = (int)(Math.random() * 32 + 8);

B

int rand = (int)(Math.random() * 32 - 23);

C

int rand = (int)(Math.random() * 31 - 8);

D

int rand = (int)(Math.random() * 15 + 23);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#16test6ing611 0m 00s 100
#2jeonsaw172311 0m 33s 67
#3patrickmeijer00912 0m 46s 44
#4keithy.mcbeefy11 0m 58s 42
#5angelajxi1101 0m 00s -10
#6akerayseduru77701 0m 00s -10
#7parth.taur22711 2m 37s -57
#8lsj0803092211 2m 44s -64
#9bommasam00003 0m 41s -71
Items per page:
10
1 – 9 of 9
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|