subject

The code segment below is intended to randomly print one of the values 2, 4, 6, or 8 with equal probability.
int val = /* missing code */ ;
val *= 2;
System. out. print(val);
Which of the following can be used to replace /* missing code */ so that the code segment works as intended?
a. Math. random() * 4 + 1
b. Math. random() * 8
c. (int) (Math. random() * 4)
d. (int) (Math. random() * 4 + 1)
e. (int) (Math. random() * 8 + 1)

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
question
Computers and Technology, 23.06.2019 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
What are "open-loop" and "closed-loop" systems
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
It is not necessary to develop strategies to separate good information and bad information on the internet. true or false
Answers: 1
You know the right answer?
The code segment below is intended to randomly print one of the values 2, 4, 6, or 8 with equal prob...
Questions
question
Mathematics, 18.02.2021 19:30
question
Mathematics, 18.02.2021 19:30
question
Mathematics, 18.02.2021 19:30
Questions on the website: 13722360