Your Name:

6.1 In the periods array shown in Figure 6.2, why would the following expression be invalid: periods[7].mins

(a) mins is not a method of periods
(b) 7 is outside the range of the array
(c) the 7th object has not been created
(d) the expression should be periods[7].mins()

6.2 Consider the IntArray class under 'Array and class interaction'. To create such an IntArray, which of the following should we use?

(a) IntArray A = new IntArray()
(b) IntArray A = new IntArray(100)
(c) IntArray A[] = new IntArray[100]
(d) IntArray A(100)

6.3 The statement that ensures that the Stats class gets into the myutilities package is:

(a) imports myutilities;
(b) package myutilities;
(c) package Stats;
(d) import myutilities.Stats;

6.4 If we create a 10 ? 10 table of strings, then the string in the fifth row and first column is referred to by:

(a) table [5][1]
(b) table [5,11]
(c) table [4][0]
(d) table [4][1]

6.5 When using the Graph class, the method that we must call to see the graph is

(a) showGraph( )
(b) nextGraph( )
(c) the constructor
(d) setVisible(true)

6.6 The reason why the selectionSort method has a parameter n as well as the array A is because:

(a) the length of A is not known inside the method
(b) we may only want to sort some of A's elements
(c) an n value of zero shows that the array may not yet have been initialized
(d) n is not necessary, actually

6.7 The keys and values of a hash table can be (where anything means object or primitive value)
(a) anything
(b) objects only
(c) key can be anything, value must be an object
(d) value can be anything, key must be an object

6.8 The statement for getting a string value from a hash table called table is:
(a) String s = t.get( )
(b) String s = (String) t.nextElement( )
(c) String s = (String) t.get( )
(d) not enough information given

6.9 If an array is declared as int A[ ] = {2, 4, 6, 8}; and we try to access A[5], what do we get?
(a) the value 8
(b) the value 0
(c) an arrayOutOfBoundsException
(d) a NullPointerException

6.10 To get the number of elements in an array A, we use
(a) A.length( )
(b) length(A)
(c) A.length
(d) A.length-1