KnowledgeBoat Logo
|

Computer Applications

Study the method and answer the given questions.

public void sampleMethod()
{   for (int i=0; i < 3; i++)
    {   for (int j = 0; j<2; j++)
        {int number = (int)(Math.random() * 10);
        System.out.println(number); }}}
  1. How many times does the loop execute?
  2. What is the range of possible values stored in the variable number?

Java Math Lib Methods

ICSE 2014

13 Likes

Answer

  1. The loops execute 6 times.
  2. The range is from 0 to 9.

Answered By

5 Likes


Related Questions