Home » JAVA Programming » Numbers » Question
  1. What would be the output of following code snippet?
    int ran = random.nextInt(10) + 1;
    1. Random number between 1 to 10, excluding 10
    2. Random number between 1 to 10, excluding 1 and 10
    3. Random number between 1 to 10, including 1 and 10
    4. Random number between 1 to 10, excluding 1
    5. None of these
Correct Option: C

random.nextInt(10) + 1; returns random numbers between 1 to 10 including 1 and 10.



Your comments will be displayed only after manual approval.