-
What is the value of “n” after this line of code has been executed?
double n = Math.round ( 4.5 + Math.random() );
-
- 1
- 2
- 3
- 4
- 5
Correct Option: E
The Math.random() method returns a number greater than or equal to 0 and less than 1. so 4.5 will be greater than or equal to 4.5 and less than 5.5, we can be sure that Math.round() will round that number to 5.