Deck 20: Generic Collections

Full screen (f)
exit full mode
Question
Which of the following performs a boxing conversion?

A)int x = 7;
B)Integer x = 7;
C)Neither of the above.
D)Both of the above.
Use Space or
up arrow
down arrow
to flip the card.
Question
Interface Collection contains __________ operations (i.e. ,operations performed on the entire collection).

A)aggregate.
B)composite.
C)integral.
D)bulk.
Question
The collections framework algorithms are __________,i.e. ,each of these algorithms can operate on objects that offer given interfaces without concern to the underlying implementations.

A)stable.
B)lexicographical.
C)polymorphic.
D)implementation dependent.
Question
LinkedList method listIterator returns a(n)__________.

A)Iterator.
B)List.
C)sub list.
D)bidirectional iterator.
Question
Java SE 7 supports type inferencing with the <> notation in statements that declare and create generic type variables and objects.For example,the following line: List< String > list = new ArrayList< String >();
Can be written as:

A)List<> list = new ArrayList<>();
B)List<> list = new ArrayList< String >();
C)List< String > list = new ArrayList<>();
D)List< String > list = new ArrayList();
Question
__________ allows a program to walk through the collection and remove elements from the collection.
E)Set.
F)Queue.
G)Iterator.h.List.
Question
Which statement is false?

A)When a List is backed up with an array,any modifications made through the List view change the array.
B)When a List is backed up with an array,any modifications made to the array change the List view.
C)The only operation permitted on the view returned by Arrays method asList is delete,which deletes the value from the view and the backing array.
D)Adding elements to the view returned by Arrays method asList results in an UnsupportedOperationException.
Question
The classes and interfaces which comprise the collections framework are members of package ________.

A)java.util.
B)javax.swing.
C)java.collections.
D)java.collection.
Question
Comparator method compare should return ________ if the first argument is greater than the second argument.

A)a positive int value.
B)zero.
C)a negative int value.
D)a String.
Question
Which of the following performs an unboxing conversion? Assume x refers to an Integer object.

A)int y = x;
B)Integer y = x;
C)Neither of the above.
D)Both of the above.
Question
Collections method ___________ returns a Comparator object that orders the collection's elements in reverse order.

A)rotate.
B)shuffle.
C)reverse.
D)reverseOrder.
Question
Which statement is false?

A)A List is an ordered Collection.
B)A List cannot contain duplicate elements.
C)A List is sometimes called a sequence.
D)Lists are zero based.
Question
Which statement is false?

A)A ListIterator accesses the elements of a List.
B)Class ArrayList is a fixed-size array.
C)A LinkedList is a linked list implementation of a List.
D)ArrayLists execute faster than Vectors because they are not thread safe.
Question
Algorithm __________ randomly orders a List's elements.

A)randomShuffle.
B)randomPlacement.
C)fiftyTwoCardPickup.
D)shuffle.
Question
Which of these is not an example of a "real-life" collection?

A)The cards you hold in a card game.
B)Your favorite songs stored in your computer.
C)The players on a soccer team.
D)The number of pages in a book.
Question
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.
Question
Iterator method __________ determines whether the Collection contains more elements.

A)hasNext.
B)next.
C)contains.
D)containsNext.
Question
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.
Question
Which of the following does not implement interface List?

A)ArrayList.
B)LinkedList.
C)Vector.
D)ListIterator.
Question
Collections method sort that accepts a List as an argument sorts the elements of a List,which must implement the __________ interface.

A)Comparable.
B)Comparator.
C)Compare.
D)Ordering.
Question
PriorityQueue method __________ inserts an element at the appropriate location in the queue.

A)offer.
B)push.
C)poll.
D)peek.
Question
Which statement is false?

A)Queue is a new collection interface introduced in J2SE 5.0.
B)Queue and PriorityQueue are included in the java.util package.
C)PriorityQueue orders elements in increasing order,so that smallest value will be the first element removed from PriorityQueue.
D)Queue extends interface Collection.
Question
Which statement about hashing is false?

A)Hashing facilitates high-speed storing and retrieval of data.
B)Two different data items can hash to the same cell;this is called a collision.
C)A load factor of 0.5 usually results in good hashing performance,but less efficient utilization of memory.
D)A load factor of 1.0 usually results in good hashing performance,but less efficient utilization of memory.
Question
Which statement is false?

A)All built-in collections are synchronized.
B)Concurrent access to a Collection by multiple threads could cause indeterminate results or fatal errors.
C)To prevent potential threading problems,synchronization wrappers are used around collection classes that might be accessed by multiple threads.
D)A synchronization wrapper class receives method calls,adds some functionality for thread safety and then delegates the calls to the wrapped class.
Question
The collections framework provides various __________ collection interfaces from which the programmer can quickly "flesh out" complete customized implementations.

A)abstract.
B)concrete.
C)structured.
D)unstructured.
Question
If the desired Object is not found,binarySearch returns __________.

A)a positive value
B)zero
C)a negative value
D)an ObjectNotFoundError.
Question
Which statement is false?

A)SortedSet extends Set.
B)Class SortedSet implements TreeSet.
C)When a HashSet is constructed,it removes any duplicates in the Collection.
D)By definition,a Set object does not contain any duplicates.
Question
Which statement is false?

A)The Collections API provides a set of public static methods for converting collections to unmodifiable versions.
B)Unmodifable wrappers throw ModificationExceptions if attempts are made to modify the collection.
C)You can use an unmodifiable wrapper to create a collection that offers read-only access to others while allowing read-write access to yourself.
D)You can create the kind of collection mentioned in part (c)simply by giving others a reference to the unmodifiable wrapper while you also retain a reference to the wrapped collection itself.
Question
To find the smallest and largest element of a Collection,use Collections methods _________ and __________.

A)least,greatest.
B)small,large.
C)first,last.
D)min,max.
Question
Map method ________ is used to determine whether a map contains a mapping for the specified key.

A)containsKey.
B)hasKey.
C)containsMapping.
D)hasMapping.
Question
Class Collections provides algorithms for reversing,filling and copying ________.

A)Lists.
B)Collections.
C)Arrays.
D)Stacks.
Question
__________ methods enable a program to view a portion of a collection.

A)Focus-view.
B)Range-view.
C)Delimiter-view.
D)Subset-view.
Question
Stack method __________ looks at the top element of a stack without removing that element.

A)glance.
B)peek.
C)look.
D)sample.
Question
Maps allocate keys to values and cannot contain duplicate keys,i.e. ,the key-to-value mapping is a __________ mapping.

A)many-to-many.
B)many-to-one.
C)one-to-many.
D)one-to-one.
Question
Collections method __________ returns true if two Collections have no elements in common.

A)shuffle.
B)contains.
C)hasCommon.
D)disjoint.
Question
A Properties object is a __________ Hashtable object.

A)transient.
B)persistent.
C)polymorphic.
D)protected.
Question
Which statement is false?

A)Java does not guarantee which item will be found first when a binarySearch is performed on a List containing multiple elements equivalent to the search key.
B)If the search key is found,method binarySearch returns the List index (position relative to 1)of the element containing the search key.
C)The binary search algorithm is fast.
D)Method binarySearch takes a List as the first argument.
Question
If no elements are in the Stack,method pop throws an __________.

A)OutOfMemoryError.
B)OutOfMemoryException.
C)EmptyStackError.
D)EmptyStackException.
Question
Most objects in Java can now be output and input with Java's object __________.

A)encapsulation.
B)overloading.
C)Serialization.
D)reflection.
Question
Method shuffle is a member of __________.

A)class Arrays.
B)class Collections.
C)interface Collection.
D)Interface List.
Question
Which of the following is not an abstract implementation provided by the collections framework?

A)AbstractCollection.
B)AbstractTree.
C)AbstractMap.
D)AbstractList.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/41
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 20: Generic Collections
1
Which of the following performs a boxing conversion?

A)int x = 7;
B)Integer x = 7;
C)Neither of the above.
D)Both of the above.
B
2
Interface Collection contains __________ operations (i.e. ,operations performed on the entire collection).

A)aggregate.
B)composite.
C)integral.
D)bulk.
D
3
The collections framework algorithms are __________,i.e. ,each of these algorithms can operate on objects that offer given interfaces without concern to the underlying implementations.

A)stable.
B)lexicographical.
C)polymorphic.
D)implementation dependent.
C
4
LinkedList method listIterator returns a(n)__________.

A)Iterator.
B)List.
C)sub list.
D)bidirectional iterator.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
5
Java SE 7 supports type inferencing with the <> notation in statements that declare and create generic type variables and objects.For example,the following line: List< String > list = new ArrayList< String >();
Can be written as:

A)List<> list = new ArrayList<>();
B)List<> list = new ArrayList< String >();
C)List< String > list = new ArrayList<>();
D)List< String > list = new ArrayList();
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
6
__________ allows a program to walk through the collection and remove elements from the collection.
E)Set.
F)Queue.
G)Iterator.h.List.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
7
Which statement is false?

A)When a List is backed up with an array,any modifications made through the List view change the array.
B)When a List is backed up with an array,any modifications made to the array change the List view.
C)The only operation permitted on the view returned by Arrays method asList is delete,which deletes the value from the view and the backing array.
D)Adding elements to the view returned by Arrays method asList results in an UnsupportedOperationException.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
8
The classes and interfaces which comprise the collections framework are members of package ________.

A)java.util.
B)javax.swing.
C)java.collections.
D)java.collection.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
9
Comparator method compare should return ________ if the first argument is greater than the second argument.

A)a positive int value.
B)zero.
C)a negative int value.
D)a String.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following performs an unboxing conversion? Assume x refers to an Integer object.

A)int y = x;
B)Integer y = x;
C)Neither of the above.
D)Both of the above.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
11
Collections method ___________ returns a Comparator object that orders the collection's elements in reverse order.

A)rotate.
B)shuffle.
C)reverse.
D)reverseOrder.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
12
Which statement is false?

A)A List is an ordered Collection.
B)A List cannot contain duplicate elements.
C)A List is sometimes called a sequence.
D)Lists are zero based.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
13
Which statement is false?

A)A ListIterator accesses the elements of a List.
B)Class ArrayList is a fixed-size array.
C)A LinkedList is a linked list implementation of a List.
D)ArrayLists execute faster than Vectors because they are not thread safe.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
14
Algorithm __________ randomly orders a List's elements.

A)randomShuffle.
B)randomPlacement.
C)fiftyTwoCardPickup.
D)shuffle.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
15
Which of these is not an example of a "real-life" collection?

A)The cards you hold in a card game.
B)Your favorite songs stored in your computer.
C)The players on a soccer team.
D)The number of pages in a book.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
16
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.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
17
Iterator method __________ determines whether the Collection contains more elements.

A)hasNext.
B)next.
C)contains.
D)containsNext.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
18
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.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following does not implement interface List?

A)ArrayList.
B)LinkedList.
C)Vector.
D)ListIterator.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
20
Collections method sort that accepts a List as an argument sorts the elements of a List,which must implement the __________ interface.

A)Comparable.
B)Comparator.
C)Compare.
D)Ordering.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
21
PriorityQueue method __________ inserts an element at the appropriate location in the queue.

A)offer.
B)push.
C)poll.
D)peek.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
22
Which statement is false?

A)Queue is a new collection interface introduced in J2SE 5.0.
B)Queue and PriorityQueue are included in the java.util package.
C)PriorityQueue orders elements in increasing order,so that smallest value will be the first element removed from PriorityQueue.
D)Queue extends interface Collection.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
23
Which statement about hashing is false?

A)Hashing facilitates high-speed storing and retrieval of data.
B)Two different data items can hash to the same cell;this is called a collision.
C)A load factor of 0.5 usually results in good hashing performance,but less efficient utilization of memory.
D)A load factor of 1.0 usually results in good hashing performance,but less efficient utilization of memory.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
24
Which statement is false?

A)All built-in collections are synchronized.
B)Concurrent access to a Collection by multiple threads could cause indeterminate results or fatal errors.
C)To prevent potential threading problems,synchronization wrappers are used around collection classes that might be accessed by multiple threads.
D)A synchronization wrapper class receives method calls,adds some functionality for thread safety and then delegates the calls to the wrapped class.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
25
The collections framework provides various __________ collection interfaces from which the programmer can quickly "flesh out" complete customized implementations.

A)abstract.
B)concrete.
C)structured.
D)unstructured.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
26
If the desired Object is not found,binarySearch returns __________.

A)a positive value
B)zero
C)a negative value
D)an ObjectNotFoundError.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
27
Which statement is false?

A)SortedSet extends Set.
B)Class SortedSet implements TreeSet.
C)When a HashSet is constructed,it removes any duplicates in the Collection.
D)By definition,a Set object does not contain any duplicates.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
28
Which statement is false?

A)The Collections API provides a set of public static methods for converting collections to unmodifiable versions.
B)Unmodifable wrappers throw ModificationExceptions if attempts are made to modify the collection.
C)You can use an unmodifiable wrapper to create a collection that offers read-only access to others while allowing read-write access to yourself.
D)You can create the kind of collection mentioned in part (c)simply by giving others a reference to the unmodifiable wrapper while you also retain a reference to the wrapped collection itself.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
29
To find the smallest and largest element of a Collection,use Collections methods _________ and __________.

A)least,greatest.
B)small,large.
C)first,last.
D)min,max.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
30
Map method ________ is used to determine whether a map contains a mapping for the specified key.

A)containsKey.
B)hasKey.
C)containsMapping.
D)hasMapping.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
31
Class Collections provides algorithms for reversing,filling and copying ________.

A)Lists.
B)Collections.
C)Arrays.
D)Stacks.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
32
__________ methods enable a program to view a portion of a collection.

A)Focus-view.
B)Range-view.
C)Delimiter-view.
D)Subset-view.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
33
Stack method __________ looks at the top element of a stack without removing that element.

A)glance.
B)peek.
C)look.
D)sample.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
34
Maps allocate keys to values and cannot contain duplicate keys,i.e. ,the key-to-value mapping is a __________ mapping.

A)many-to-many.
B)many-to-one.
C)one-to-many.
D)one-to-one.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
35
Collections method __________ returns true if two Collections have no elements in common.

A)shuffle.
B)contains.
C)hasCommon.
D)disjoint.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
36
A Properties object is a __________ Hashtable object.

A)transient.
B)persistent.
C)polymorphic.
D)protected.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
37
Which statement is false?

A)Java does not guarantee which item will be found first when a binarySearch is performed on a List containing multiple elements equivalent to the search key.
B)If the search key is found,method binarySearch returns the List index (position relative to 1)of the element containing the search key.
C)The binary search algorithm is fast.
D)Method binarySearch takes a List as the first argument.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
38
If no elements are in the Stack,method pop throws an __________.

A)OutOfMemoryError.
B)OutOfMemoryException.
C)EmptyStackError.
D)EmptyStackException.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
39
Most objects in Java can now be output and input with Java's object __________.

A)encapsulation.
B)overloading.
C)Serialization.
D)reflection.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
40
Method shuffle is a member of __________.

A)class Arrays.
B)class Collections.
C)interface Collection.
D)Interface List.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
41
Which of the following is not an abstract implementation provided by the collections framework?

A)AbstractCollection.
B)AbstractTree.
C)AbstractMap.
D)AbstractList.
Unlock Deck
Unlock for access to all 41 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 41 flashcards in this deck.