Question: I have some questions about Java regarding arrays. Question 12 Which of the following is true about a sifting operation? The operation may produce more
I have some questions about Java regarding arrays.
Question 12
Which of the following is true about a sifting operation?
| 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 13
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 14
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 |
Flag this Question
Question 15
The last 3 lines in the following program are supposed to swap the two elements in the array 'blooms' identified by the index values 'mary' and 'john'. Choose from among the answers listed the correct statement for the middle of these 3 lines: Flower[] blooms = ... // Assume this array is filled with object references int mary, john; // Assume these variables have values assigned to them ... Flower temp = blooms[mary]; // What statement goes here?? blooms[john] = temp;
| john = mary; |
| temp = blooms[john]; |
| blooms[mary] = blooms[john]; |
| blooms[john] = blooms[mary]; |
| None of the above -- no statement is needed. |
Flag this Question
Question 17
What is printed out by the following short program? double[] x1 = {3.3, 4.4, 5.5, 6.6}; double[] x2 = x1; x2[1] = 24.0; double x = x1[1] * 2; System.out.println(x1[1]);
| 3.3 |
| 4.4 |
| 6.6 |
| 8.8 |
| 24.0 |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
