Which of the following defines a method doubleEach that retu
Solution
Answer is A
public double[] dobleEach(double [] input)
{
double[] temp= new double[input.length];
for(int i=0;i<input.length;i++)
{
temp[i]=input[i] * 2.0;
}
return temp;
}
---------------------
for more info execute following code
package chegg;
public class MethodCall {
public double[] dobleEach(double [] input)
{
double[] temp= new double[input.length];
for(int i=0;i<input.length;i++)
{
temp[i]=input[i] * 2.0;
}
return temp;
}
public static void main(String[] args) {
double a[]={2.0,3.0,4.0,6.0};
MethodCall m=new MethodCall();
int i;
for(i=0;i<4;i++)
System.out.println(a[i]);
a=m.dobleEach(a);
for(i=0;i<4;i++)
System.out.println(a[i]);
}
}
output :
2.0
3.0
4.0
6.0
4.0
6.0
8.0
12.0
---------------------------------------------------------------------------------------------
If you have any query, please feel free to ask.
Thanks a lot.

