Question
Question 100.05 pts A loop is being used to find the lowest value in a double array named numbers. Which of the following statements performs
Question 100.05 pts
A loop is being used to find the lowest value in a double array named numbers. Which of the following statements performs a useful initialization of the accumulator?
double lowestValue = 0; |
double lowestValue = numbers; |
double lowestValue = numbers[0]; |
double lowestValue; // no initialization needed |
Any of the above. |
Flag this Question
Question 110.05 pts
The following bit of code is attempting to find the sum of all the elements in the array 'codes'. One line contains a logic error. Which line is it? long[] codes = ...; // Assume the array has been filled with values ... long sum = 0; // line 1 for ( int i = 1; i < codes.length; i++ ) { // line 2
sum = sum + codes[i]; // line 3
}
line 1 |
line 2 |
line 3 |
Flag this Question
Question 120.05 pts
Which of the following is true about a siftingoperation?
The operation may produce more than one result. |
The operation may produce no results. |
The search must continue even after a match is found; the entire collection must be examined. |
All of the above. |
None of the above. |
Flag this Question
Question 130.05 pts
The following bit of code is attempting to find the average number of characters in all of the Strings in a String array. One line has a syntax error. Which line is it? String[] names = ... // Assume the array has been filled with values ... double averageLength = 0; // line 1 int i; for (i = 0; i < names.length(); i++ ) { // line 2
averageLength += names[i].length(); // line 3
} averageLength = averageLength / i; // line 4
line 1 |
line 2 |
line 3 |
line 4 |
Flag this Question
Question 140.05 pts
The following bit of code is attempting to find the x-coordinate of the Point that is farthest to the right in the x-y plane in the array 'points'. One line contains an error. Which line is it? Point[] points = ... // Assume the array has been filled with Point object references ... double xMax = points[0].getX(); // line 1 for ( int i = 1; i < points.length; i++ ) { // line 2
if ( points[i].getX() > xMax ) {// line 3
xMax = points[i]; // line 4
}
}
line 2 |
line 3 |
line 4 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started