Discussion
What two statements are true about the result obtained from calling Math.random()?
1. The result is less than 0.0.
2. The result is greater than or equal to 0.0.
3. The result is less than 1.0.
4. The result is greater than 1.0.
5. The result is greater than or equal to 1.0.
Answer: B
Correct answer: 2 and 3
Statements 2 and 3 state the two halves of the range: the result is greater than or equal to 0.0 and strictly less than 1.0. Statements 1, 4 and 5 all put it outside that interval. The asymmetry - inclusive at the bottom, exclusive at the top - is deliberate and is what makes the value safe to multiply by a range and truncate.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development