Sping 03 Midterm 1 Solution 1 A. 12 B. Yes, an array index out of bounds exception could occur if list.length < 100 (or words to that effect) C. Runtime error or Exception or Null Pointer Exception D. 5 20 10 15 50 20 or syntax error E. 2 3 4 9 2 3 F. Syntax error G. false ( ignore capitilization, f = -1) H. true ( ignore capitilization, t = -1) I. 15 30 J. 12 10 20 10 K. 100 L. 10 M. 25 N. 19 O. 0.5 or .5 2. double[] result = new double[limit + 1]; double val; for(int x = 0; x < result.length; x++) { val = 0; for(int exp = 0; exp <= p.getDegree(); exp++) val += Math.pow(x,exp) * p.getCoefficient(exp); result[x] = val; } return result; 3. char[][] result = new char[rows][cols]; int currentChar = 0; for(int row = 0; row < rows; row++) for(int col = 0; col < cols; col++) { results[row][col] = list[currentChar]; currentChar = (currentChar + 1) % list.length; } return result; 4. public class Direction { public static final int NORTH = 0; public static final int EAST = 90; public static final int SOUTH = 180; public static final int WEST = 270; private int iMyDegrees; public Direction() { iMyDegrees = 0; } public Direction(int degrees) { while(degrees < 0) degrees += 360; iMyDegrees = degrees % 360; } public int getDegrees() { return iMyDegrees; } public void reverse() { iMyDegrees = (iMyDegrees + 180) % 360; } public boolean equals(Object other) { return iMyDegrees == ((Direction)other).iMyDegrees; } }