About Question com.enthuware.jfcja.v8.2.419 :
Posted: Sat Oct 02, 2021 1:21 pm
1 + Math.round(Math.random()*9) will return a random number between 1 and 10.
Math.random()*9 will return a double between 0.0 to less than 9.0. Rounding it will give you a range of 0.0 to 10.0 (both inclusive). Adding 1 to it will give you a range of 1.0 to 11.0 (both inclusive).
the option says that expression will return random number between 1 and 10, but explanation says that it will give a you a range of 1.0 to 11.0 (both inclusive). so why this option is correct statement?
Math.random()*9 will return a double between 0.0 to less than 9.0. Rounding it will give you a range of 0.0 to 10.0 (both inclusive). Adding 1 to it will give you a range of 1.0 to 11.0 (both inclusive).
the option says that expression will return random number between 1 and 10, but explanation says that it will give a you a range of 1.0 to 11.0 (both inclusive). so why this option is correct statement?