Name: ________________________________

CSE373 Spring Quarter
University of Washington
Miniquiz #3
April 6, 2005
Closed book, closed notes, closed neighbor; no calculators
1 point per part except as noted

. (1 pt. each)
Explain what, if anything, is wrong with the following code fragment?  Circle all that apply.

List mywords = new ArrayList(); //line 1

mywords.add("2"); //line 2

mywords.add('2'); //line 3

  1. On line 1, "List" must be "ArrayList"
  2. On line 3, can't add a character to a list
  3. On line 3, can't add a duplicate value to a list
  4. On line 3, not allowed to have objects of more than one type in a list
notes and answers 
 
.
Given this method header:

boolean checkSet(Set aSet);

How can the method determine if there are any duplicate values in aSet?  (Trick question)

                                                          
 
. (2 pts.)
Given this method header:

void printSet(Set aSet);

Is there a way that the method can print out all the elements in the set?  Explain briefly.

                                                               ___ yes

___ no

 

notes and answers 
 
.
One property that a proper equals method must have is that a.equals(a) be true for any object a (of the proper type).  This is called the _____________ property.
  1. reflexive                         
  2. symmetric
  3. anti-symmetric
  4. anti-aircraft
  5. transitive
notes and answers 
 
.
(free bonus point)

With respect to the CSE373 Message Board....

  1. I have posted to it
  2. I have been reading it daily but haven't posted anything yet
  3. I have read it at least once
  4. I know about it but looked at it yet
  5. Never heard of it
notes and answers