Practice Test 2 --- In addition to questions similar to those below, there will be a few suprise questions, based on assignment material. --- Write a static method with two integer parameters - low and high (assume low <= high). The method must use a for loop to compute and return the sum of the even numbers from low to high (inclusive). Include all necessary variable declarations. --- Write javadoc comments for the method above --- Write a single statement which outputs the sum of the even numbers from 1 to 100 using the method above. --- Write a static method that has a single character parameter. The method must use a do-while loop to read characters from the user until the parameter value is entered. The method must count and return the total number of characters entered (including parameter). Assume all characters are on the same line of input. Include all other necessary variable declarations. --- What is the output of the following code segment? (Show memory boxes for partial credit.) final int SIZE = 5; int index; int row, col; double[] ra = {2.3, 3.4, 5.6, 2.5}; for (index=ra.length-1; index >= 0; index--) System.out.print(ra[index] + " "); System.out.println(); int[][] rad = new int[SIZE/2][SIZE]; for (row=0; row < SIZE/2; row ++) for (col=0; col < SIZE; col ++) rad[row][col] = row + col; for (col=0; col < SIZE; col++) System.out.print(rad[1][col]); System.out.println(); for (row=0; row < SIZE/2; row++) System.out.print(rad[row][4]); System.out.println(); } } --- What word is used to indicate that a method can be called from anywhere (in or outside of its class)? --- What word is used to indicate that a class variable will have one memory location that is shared by all instances of the class? --- What word is used to indicate that a method does not return a value? --- Given the class Gift definition on the next page, what is the output of this program? class main2 { public static void main(String[] args) { Gift p1 = new Gift(); p1.printall(); Gift p2 = new Gift(10, 20, 30, 20.50, "Manny"); p2.printall(); Gift.changeMax(10.0); p2.printall(); p1.forwhom = "Moe"; p1.printall(); Gift p3 = new Gift(3, 4, 5, 15, "Jack"); p3.printall(); } } --- Write an instance method which could be added to the class Gift that will take a double parameter, and change the cost of the current object to that value only if the parameter is <= MAXCOST. Otherwise it should be unchanged. Return the current object cost. --- Write a Java statement to create an array that could hold 10 Gift objects. ---- Write a Java statement to put a default gift into the first spot in the array from the above question. ---- Write a Java statement to put a 5x7x9 inch gift costing $43.24 for yourself into the last position in the array declared above. ---- Write a Java statement to display the details of the gift stored in the first array element. ----- // for the previous questions class Gift { public String forwhom; private int height, width, depth; private double cost; private static double MAXCOST = 100.00; public Gift() { height = 3; width = 4; depth = 5; forwhom = "Dr. H"; cost = 0.0; } public Gift(int h, int w, int d, double c, String s) { height = h; width = w; depth = d; if (c <= MAXCOST) cost = c; else cost = MAXCOST; forwhom = s; } public void printall() { System.out.println(height + "x" + width + "x" + depth); System.out.println("$" + cost + " for " + forwhom); } public static void changeMax(double d) { if (d > 0) MAXCOST = d; } } --- Write a code segment which will output a random integer between 13 and 20, inclusive. Include ALL variable declarations.