Name: ______

SSN:______

F2000 ISQS 6337 Exam 2 Please remember that neatness counts, if I cannot easily read it I will not try! Do not do any more than I ask! If you try to create entire programs and user interfaces you WILL NOT FINISH!!!

1. Provide brief explanations of the following (5 points each): a. Method overriding versus overloading b. The differences between public, private, protected, and package access c. An abstract class versus an interface

// For questions d & e assume you have the following code: BankAccount account1 = new BankAccount(1000); // a new account with a balance of 1000 BankAccount account2 = account1; BankAccount account3; account2.deposit(500); // puts 500 more in account2 account3.withdraw(500) // takes 500 out of account3

d. What is the balance in account1 & account2 and why? e. What is the status of account3? f. The is-a versus the has-a relationship between objects. g. Polymorphism, dynamic binding, and how they relate to inheritance. h. All classes, other than Object, have a parent class. Explain implicit versus explicit calls to the constructor of a parent class and where they occur in the child.

2. Write a method public String findLastName(String[] s, String sLastName)

that takes an array of last names and a single last name as arguments. When finished the method returns a string indicating the index where the last name was found (as: “Durrett was found in index 7”) or a string indicating the the last name was not found (as: “Sorry your last name is not in the array”).

Write only the method and NOTHING ELSE. (20 points)

3. Write the code necessary to call the method above. Write only the variable definitions and the method call. Be sure to define and initialize the array. (10 points)

4. Create a class BankAccount that stores information about an individual bank account. Make sure to include the owner’s Name and Social Security Number along with the current balance. Do not allow for any implicit calls or extensions in the class (ie make sure to extend the appropriate class and to call its constructor.) Use appropriate access modifiers in all cases. Make sure to create the following methods: a. a default constructor that initializes the owner’s name and SSN to yours and the balance to 0; b. a constructor that allows initializing of all attributes c. mutator methods: void deposit(double d); void withdrawal(double d); d. accessor method: double getBalance(); (30 points)