COM1204 Object-Oriented Design -- Quiz 2 -- Thursday, July 12th

Summer 2001 -- Professor Futrelle
College of Computer Science, Northeastern U., Boston, MA

PRINT your name clearly ________________________________________________ Your ID no. ________________

Question 1.

Write the specifications (REQUIRES, MODIFIES and EFFECTS) for the following function.

        public static boolean doublesOne(float[] arr, int which) {
            if (arr == null || which >= arr.length) return false;
            arr[which] *= 2.0;
            return true;
        } // doublesOne()

There is no need to copy the function definition; just write the specification text itself.

Question 2.

Assume that accounts is a member variable of type Vector of a class AccountSet. Each element of accounts is of type Account. Write a method of AccountSet, checkAll(), that calls the Account method checkAccount() on each element of accounts. It should do this by defining an Iterator object for accounts and then using the standard while loop. You needn't write a definition of either class or of checkAccount(); just write the definition of checkAll().

Question 3.

Assume you have a class Supah and a subclass of it, Subber. Write a definition for a constructor Subber(int, int) that calls a superclass constructor, passing it only the first Subber argument and sets an instance variable inst of Subber to the second argument.