Solved

Consider the Following Code Snippet

Question 34

Multiple Choice

Consider the following code snippet. What does the array contain at the end of the program?
Public static fillWithRandomNumbers(double[] values)
{
Double[] numbers = new double[values.length];
For (int i = 0; i < numbers.length; i++)
{
Numbers[i] = Math.random() ;
}
Values = numbers;
}
Public static void main(String[] args)
{
Double[] num = new double[20];
FillWithRandomNumbers(num) ;
}


A) 20 random numbers
B) Undefined data due to compilation error
C) 20 zeros because array num is not changed by method
D) Array index bound error

Correct Answer:

verifed

Verified

Unlock this answer now
Get Access to more Verified Answers free of charge

Related Questions