Deck 2: Lists and the Collections Framework
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
Play
Full screen (f)
Deck 2: Lists and the Collections Framework
1
Because an ArrayList<E> is an indexed collection, you can access its elements using a subscript.
False
2
The actual object type stored in an object of type CollectionClassName<E> is specified when the object is created.
True
3
Array reallocation is effectively an O(1) operation.
True
4
The Node class for a double-linked list has references to the data and to the next and previous nodes.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
The ArrayList<E> has the limitation that the add and remove methods operate in O(n2) time.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
A Node is generally defined inside another class, making it a(n) _____________ class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
The language feature introduced in Java 5.0 called generic collections is also known as ___________________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
Give an example of an unboxing statement in Java 5.0.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
Character ch = 'x' in Java 5.0 is equivalent to Character ch = new Character('x') in earlier Java versions.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
The ____________________ interface is used to pass collections of data as a method parameter in the most general way.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
The ArrayList<E> class is part of the package called ____________________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
Iterator objects throw a(n) ____________________ if they are asked to retrieve the next element after all elements have been processed.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
If a call to remove (java.util.Iterator interface) is not preceded by a call to next, remove will throw a(n) ____________________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
____________________ types allow us to define a collection such as an ArrayList of a specific type.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
If you want to remove two consequtive elements in a list, a separate call to ____________________ must occur before each call to remove.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
To obtain a ListIterator, you call the ____________________ method of the LinkedList class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
The Collection interface is the root of the collection hierarchy.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
A(n) ____ is an indexed data structure, which means you can select its elements in arbitary order as determined by the subscript value.
A) String
B) stack
C) array
D) list
A) String
B) stack
C) array
D) list
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following can be done with an array object?
A) Traverse the list structure without having to manage a subscript.
B) Increase or decrease its length, which is fixed.
C) Add an element at a specified position without shifting the other elements to make room.
D) Remove an element at a specified position without shifting the other elements to fill in the resulting gap.
A) Traverse the list structure without having to manage a subscript.
B) Increase or decrease its length, which is fixed.
C) Add an element at a specified position without shifting the other elements to make room.
D) Remove an element at a specified position without shifting the other elements to fill in the resulting gap.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
The simplest class that implements the List<E> interface is the ____ class.
A) ListIterator<E>
B) Collection<E>
C) ArrayList<E>
D) AbstractList<E>
A) ListIterator<E>
B) Collection<E>
C) ArrayList<E>
D) AbstractList<E>
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
The ____ method, of the ArrayList<E> class, creates a new array that is twice the size of the current array and then copies the contents of the current array into the new one.
A) remove
B) add
C) reallocate
D) vector
A) remove
B) add
C) reallocate
D) vector
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
In the java.util.ArrayList<E> class, which of the following returns a reference to the element at position index?
A) add(E anEntry)
B) indexOf(E target)
C) E remove(int index)
D) E get(int index)
A) add(E anEntry)
B) indexOf(E target)
C) E remove(int index)
D) E get(int index)
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
Which of the following is a subclass of Vector?
A) Stack
B) LinkedList
C) Iterator
D) Collection
A) Stack
B) LinkedList
C) Iterator
D) Collection
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
A(n) ____ is a data structure that contains a data item and one or more links.
A) collection
B) node
C) iterator
D) interface
A) collection
B) node
C) iterator
D) interface
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
You could create a circular list from a single-linked list by executing the statement ____.
A) tail.next = head;
B) head.prev = tail;
C) tail.head = next;
D) head.tail = prev;
A) tail.next = head;
B) head.prev = tail;
C) tail.head = next;
D) head.tail = prev;
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
In the Java API documentation, inner classes are called ____ classes.
A) collection
B) interface
C) nested
D) iterator
A) collection
B) interface
C) nested
D) iterator
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
The LinkedList<E> class implements the List<E> interface using a(n) ____.
A) iterator
B) interface
C) collection
D) double-linked list
A) iterator
B) interface
C) collection
D) double-linked list
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
A(n) ____________________ is a statement of any assumptions or constraints on the method data before the method begins execution.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
____________________ testing tests the software element (method, class, or program) with the knowledge of its internal structure.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
The replacement for a method that has not yet been implemented or tested is called a(n) ____________________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) ____________________ declares any necessary object instances and variables, assigns values to any of the method's inputs, calls the method, and displays the values of any outputs returned by the method.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
32
____ testing refers to testing the smallest testable piece of software.
A) Integration
B) System
C) Unit
D) Acceptance
A) Integration
B) System
C) Unit
D) Acceptance
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
____ testing involves testing the interactions among units.
A) Unit
B) System
C) Integration
D) Acceptance
A) Unit
B) System
C) Integration
D) Acceptance
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
____ testing is the testing of the whole program in the context in which it will be used.
A) Acceptance
B) Integration
C) Unit
D) System
A) Acceptance
B) Integration
C) Unit
D) System
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
____ testing is system testing designed to show that the program meets its functional requirements.
A) Unit
B) Acceptance
C) System
D) Integration
A) Unit
B) Acceptance
C) System
D) Integration
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck