Solved

Which of the Following Is Correct for Simulating the Toss

Question 108

Multiple Choice

Which of the following is correct for simulating the toss of a pair of coins to get 0 (head) or 1 (tail) with different probabilities? (Assume Random generator = new Random() ;)


A) System.out.println(generator.nextInt(1) + " " + generator.nextInt(2) ) ;
B) System.out.println((generator.nextDouble() + 2) * 2) ;
C) System.out.println(generator.nextInt(1) + " " + generator.nextInt(1) ) ;
D) System.out.println(generator.nextInt(2) + " " + generator.nextInt(2) ) ;

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions