1
visibility

What is the value of “d” in the following Java code snippet?
double d = Math.round( 2.5 + Math.random() );

  • A

    2

  • B

    3

  • C

    4

  • D

    2.5

The Math.randomO method returns a number greater than or equal to o and less than1. so 2.5 wll be greater
than or equal to 2.5 and less than 3-5, we can be sure that Math.round() will round that number to 3.