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); }}}

How many times does the loop execute?

What is the range of possible values stored in the variable number?

Views 9

Answer:

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

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.