1. for (int row = 0; row <= data.length-1; row++) { // initialize first value in the current row if (row == 0) data[0][0] = 1; else data[row][0] = data[row-1][0] * 2; // OR: data[row][0] = (int) Math.pow(2, row); // initialize all other values in the current row for (int col = 1; col <= data[row].length-1; col++) { data[row][col] = data[row][col-1] + 2 * col - 1; // OR: data[row][col] = data[row][0] + col * col; } } 2. public int compareTo(Object obj) { // compare this date to another date (obj) TimeOfDay t = (TimeOfDay) obj; if (this.hour != t.hour) return this.hour - t.hour; else if (this.minute != t.minute) return this.minute - t.minute; else return this.second - t.second; } 3. (a) Homer's balance is $1500.0 Marge's balance is %2000.0 marge.getBalance() is 500 and when added to homer's 1000.0, homers balance becomes 1500.0. Thus, homer.getBalance() is 1500 and when added to marge's 500.0 her balance is 2000.0 (b) Bart's balance is $275.0 Lisa's balance is $275.0 Watch out for the bart and lisa aliases. Both bart and lisa refer to exactly the same account object. Changes to one is "seen" by the other. bart.addInterest() adds 25.0 to the balance, so both lisa and bart variables refer to same account with 275.0 balance. (c) By the number and types of the parameters (d) FALSE. They are behaviors as they access or mutate the state. The clue is that the names are verbs. (e) overriding. 4. public Account getMinAccount(){ if (numAccounts == 0) return null; int minPosition = 0; // start with index of first account as min for (int position = 1; position < numAccounts; position++) { // check if the next account has a balance less than the // minimum found so far. if (accountArray[minPosition].getBalance() > accountArray[position].getBalance()) { minPosition = position; // found a new minimum } } return accountArray[minPosition]; } Alternate solution public Account getMinAccount(){ if (numAccounts == 0) return null; Account minAccount = accountArray[0]; // start with first account as min for (int position = 1; position < numAccounts; position++) { // check if next account has balance less than the account // with minimum balance found so far if (minAccount.getBalance() > accountArray[position].getBalance()) { minAccount = accountArray[position]; } } return minAccount; } 5. public class Car { // fields (instance variables) private int efficiency; private double fuelLevel; // constructor public Car(int fuelEfficiency) { efficiency = fuelEfficiency; fuelLevel = 0.0; // default value } // mutators public void addFuel(double amount) { fuelLevel += amount; } public void drive(int miles) { // Recall the units are (miles / MPG) = gallons fuelLevel -= (double)miles / efficiency; } // accessors public double getFuel() { return fuelLevel; } public String toString() { return efficiency + " mpg, " + fuelLevel + " gallons"; } }