Quiz 4 Flashcards
Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value mapping is a _________ mapping.
One-to-one
Stack method ________ looks at the top element of a stack without removing that element.
Peek
A recursive method ________.
Can be called indirectly through another method
When a recursive method is called to solve a problem, the method actually is capable of solving only the simplest case(s), or ________.
The base case
Iterator method ________ determines whether the Collection contains more elements.
hasNext
In recursive backtracking, if one set of recursive calls does not result in a solution to the problem, what happens?
The program returns to a previous decision point and makes a different decision
Map method ________ is used to determine whether a map contains a mapping for the specified key.
containsKey
Collections method ________ returns true if two Collections have no elements in common.
disjoint
The collections framework algorithms are ________, i.e., each of these algorithms can operate on objects that implement specified interfaces without concern for the underlying implementations.
Polymorphic
Algorithm ________ randomly orders a List’s elements.
Shuffle
Recursion often is preferable to iteration because ________.
It models the problem more logically
If the desired Object is not found, binarySearch returns ________.
Negative value
Which statement is false?
A) A collection is an object that can hold references to other objects.
B) The collection interfaces declare the operations that can be performed on each type of collection.
C) Unfortunately, collections discourage software reuse because they are non-portable.
D) Collections are carefully constructed for rapid execution and efficient use of memory.
C
Collections encourage software reuse because they are portable
Which statement is false?
A) Each primitive type has a corresponding type-wrapper class.
B) The type-wrapper classes enable you to manipulate primitive-type values as objects.
C) Type-wrapper classes are final, so you cannot extend them.
D) The methods for primitive types correspond to the methods for the corresponding type-wrapper classes.
D
Primitive types don’t have methods
When the recursion step executes ___
The original call to the method is still active