The method findLargest should return the largest of any number of double values. For example, the call findLargest (3.4, -2.6, 2.9) should return 3.4 and the call findLargest (9.2, 17.6, 3.4, -2.6, 2.9) should return 17.6. Partial code to do this is given below: double findLargest (double... values)
{
Double max = values[0];
// New code goes here
Return max;
}
What code will complete this method?
A) for (double val: values)
{
If (val > max)
Max = val;
}
B) for (int i = 1; i < values.length; i++)
{
If (i > max)
Max = i;
}
C) for (double val: values)
{
If (values[val] > max)
Max = values[val];
}
D) for (int i = 1; i < values.length; i++)
{
If (values[i] > max)
Max = i;
}
Correct Answer:
Verified
Q108: What will be printed by the statements
Q109: Assume the following variable has been declared
Q110: Assume the following variable has been declared
Q111: What will be printed by the statements
Q112: Assume the array of integers values has
Q113: Assume the method doSomething has been defined
Q114: What will be printed by the statements
Q116: Assume the following variable has been declared
Q117: What will be printed by the statements
Q118: What will be printed by the statements
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents