Single Choice Not Set

QWhich of the following options is the best for generating random integer 0 or 1?

ID: #2167 Java Constructor and Methods 1,551 views
Question Info
#2167Q ID
Not SetDifficulty
Java Constructor and MethodsTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A (int)Math.random()
  • B (int)Math.random() + 1
  • C (int)(Math.random() + 0.5)
  • D (int)(Math.random() + 0.2)
Correct Answer

Explanation

(int)(Math.random() + 0.5)

Share This Question

Challenge a friend or share with your study group.