You are not logged in.

#1 2015-06-16 05:34:51

husnain
User RankUser RankUser RankUser RankUser RankUser Rank
Administrator
From: Chichawatni,Pakistan
Registered: 2014-10-03
Posts: 8,129
Website

Random Integer:

Java Quizzes Java Language Constructors-And-Methods

Question:
Which of the following options is the best for generating random integer 0 or 1?

Option A):
(int)(Math.random() + 0.2)
Option B):
(int)(Math.random() + 0.5)
Option C):
(int)Math.random() + 1
Option D):
(int)Math.random()

Correct Answer is Option B):
(int)(Math.random() + 0.5)


You cannot discover the new oceans unless you have the courage to lose the sight of the shore.

2015-06-16 05:34:51

Advertisement
Ads By Google

Re: Random Integer:



\n

Board footer