What does the following code do?
Int sum = 0;
Final double count = 1000;
Random generator = new Random() ;
For (int i = 1; i <= count; i++)
{
Sum = sum + generator.nextInt(101) ;
}
System.out.println(sum / count) ;
A) It simulates the outcome of throwing a coin.
B) It calculates the average of 1000 random numbers between 0 and 100.
C) It performs Monte Carlo simulation of fluid dynamics.
D) It calculates the average of 1000 random numbers between 1 and 101.
Correct Answer:
Verified
Q118: What will be the output of the
Q119: What is the last output line of
Q120: What is the output of this code
Q121: Suppose that the chance to hit the
Q122: What does the following code snippet display?
Q123: Which of the following is the correct
Q124: How many times does the following loop
Q125: Which of the following code snippets will
Q126: Which of the following is correct for
Q128: What is the data type of the
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents