Your Name:

8.1 In the first Coffee Shop program (Example 8.1) the compiler would prevent access to C[0].name (i.e. there would be a compilation error) because:

(a) C[0] has not been instantiated
(b) name is declared as private
(c) 0 is not a valid index for the array
(d) a value for name has not been read in yet

8.2 If cloning for the Time class has been defined and today is a Time, then which of the following is valid?

(a) Time temp = (Time) clone(today);
(b) Time temp = Time.clone(today);
(c) Time temp = (Time) today.clone();
(d) Time temp = today.clone();

8.3 The LinkedList supplies method contains, used as in L.contains(x). It relies on

(a) there being a hash table of objects
(b) equals being defined for the objects in the list
(c) the object x being in the list
(d) the object x not being in the list

8.4 The difference between the add method in LinkedList and in ListIterator is:

(a) none
(b) where the object gets added in the list
(c) the need to provide an object cast or not
(d) whether the object can be removed afterwards

8.5 When iterating through a list L with a list iterator Lit, getting the next element is done with:

(a) L.getNext( )
(b) L.next( )
(c) Lit.hasNext( )
(d) Lit.next( )

8.6 In terms of the operations available for it, an array is more like

(a) an object
(b) a string
(c) a primitive value
(d) something quite distinct from any of these

8.7 If we declare a method Coffee equals (), we must also

(a) declare it public
(b) declare it private
(c) declare a clone for Coffee
(d) do nothing else

8.8 A difference between a nested class N and a member class M is

(a) nothing
(b) M need not have constructors
(c) M can see the members of its enclosing class
(d) N cannot have static members

8.9 The ListIterators in Coffee2 and in CoffeeShop2 both produce, when iterating, variables of type

(a) Batch
(b) Object
(c) Coffee2
(d) Date

8.10 In Example 8.2, at the end of the program, the list variable has the value

(a) coffees
(b) Java
(c) null
(d) undefined