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); }}}
- How many times does the loop execute?
- What is the range of possible values stored in the variable number?
Java Math Lib Methods
ICSE 2014
13 Likes
Answer
- The loops execute 6 times.
- The range is from 0 to 9.
Answered By
5 Likes
Related Questions
Write a Java expression for the following:
|x2 + 2xy|A Student executes the given program segment and it results in 1.0, irrespective of the value of n. State the type of the error, write the correct statement:
void solve(int n) { double power=Math.pow(n, 2/3); System.out.println(power); }The output of the statement
Math.ceil.(89.9) + Math.floor(90.5)is:- 0.0
- 180
- 180.0
- 180.4
What is the output of Math.ceil(5.4)+Math.ceil(4.5)?
- 10.0
- 11.0
- 12.0
- 9.0