Ch10 - Lists Test Bank Docx - Data Structures with Java 5e Complete Test Bank by Frank M. Carrano. DOCX document preview.

Ch10 - Lists Test Bank Docx

Chapter 10 - Lists

True/False (10)

  1. The ADT list only works for entries that are strings.
  2. The ADT list is more general than common lists and has entries that are objects of the same type.
  3. Adding entries to the end of a list does not change the positions of entries already in the list.
  4. The first entry is a list is at position 0.
  5. The entries of a list are numbered from 0 to n.
  6. When a programmer implements an ADT list, clients can use the ADT’s operations in a program without knowing how the programmer implemented the list to be able to use it.
  7. The Java Class Library contains an implementation of the ADT list that uses a resizable array instead of a linked chain.
  8. A list is an object whose data consists of unordered entries.
  9. Each entry is a list ADT is uniquely identified by its position within the list.
  10. You may replace an entry at any given position in a list.

Short Answer (7)

  1. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code?
    myList.add(“Tom”)
    myList.add(“Hank”)
    myList.add(3, “Ryan”)
    myList.add(1, “Sally”)
    myList.add(“Helen”)
  2. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code.
    myList.add(“Tom”)
    myList.add(“1, Hank”)
    myList.add(2, “Ryan”)
    myList.add(“Sally”)
    myList.add(3, “Helen”)
  3. Make a case for the designer of an interface to determine what behavior is appropriate when a collection such as a list is empty.
  4. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code.

myList.add(“horse”)
myList.add(“goat”)
myList.add(1, “fish”)
myList.add(“cat”)
myList.remove(1)
myList.add(2, “dog”)

  1. If myList is a declared ADT list and the front of the list is on the left, show the contents of the list after applying the following pseudo code.

myList.add(“horse”)
myList.add(“goat”)
myList.add(1, “fish”)
myList.add(“cat”)
myList.remove(2)
myList.add(3, “dog”)
myList.replace(2, “frog”)

  1. Given treeList is a declared ADT list that is initially empty, write a serious of list operations to generate the following list step by step.
    1. maple
    2. maple, oak
    3. maple, elm, oak
    4. palm, elm, oak

treeList.add(maple)
treeList.add(oak)
treeList.add(2, elm)
treeList.replace(1, palm)

  1. Given treeList is a declared ADT list that is initially empty, write a serious of list operations to generate the following list step by step.
    1. maple
    2. oak, maple
    3. oak, elm, maple
    4. elm, maple

treeList.add(maple)
treeList.add(1, oak)
treeList.add(2, elm)
treeList.remove(1)

Multiple Choice (17) WARNING: CORRECT ANSWERS ARE IN THE SAME POSITION AND TAGGED WITH . YOU SHOULD RANDOMIZE THE LOCATION OF THE CORRECT ANSWERS IN YOUR EXAM.

  1. In the ADT list, new entries are typically added
    1. at the end of the list
    2. at the beginning of the list in the list
    3. at a computed place in the list depending on the number of elements
  2. You can add a new entry in a list
    1. at the beginning
    2. at the end
    3. in between items
    4. all of the above
  3. If myList is a declared ADT list and the front of the list is on the left, what does the list look like after applying the following pseudo code?
    myList.add(“cat”)
    myList.add(“dog”)
    mylist.add(“fish”)
    1. cat, dog, fish
    2. fish, dog, cat
    3. cat, fish, dog
    4. dog, fish, cat
  4. If myList is a declared ADT list and the front of the list is on the left, what does the list look like after applying the following pseudo code?
    myList.add(“horse”)
    myList.add(“goat”)
    myList.add(3, “fish”)
    myList.add(1, “dog”)
    myList.add(“cat”)
    1. dog, horse, goat, fish, cat
    2. horse, goat, fish, dog, cat
    3. cat, horse, goat, fish, dog
    4. cat, fish, goat, dog, horse
  5. Given an ADT list called myList that contains 4 items entries in it, which statement will remove the first item on the list?
    1. myList.remove(1)
    2. myList.remove()
    3. myList.removeFront()
    4. myList.removeFirst()
  6. Given an ADT list called myList that contains 4 items entries in it, which statement will add a new item called x on the front of the list?
    1. myList.add(1, x)
    2. myList.add(x)
    3. myList.addFirst(x)
    4. myList.addFront(x)
  7. Which method is not meaningful for use on an empty list?
    1. remove
    2. replace
    3. getEntry
    4. all of the above
  8. Which method is well behaved when the given position is valid for the current list?
    1. add
    2. remove
    3. replace
    4. all of the above
  9. In the interface ListInterface, the method
    public void add(T newEntry);
    describes which of the following behaviors?
    1. adds a new entry to the end of the list
    2. increases the list size by 1
    3. does not affect any other entries on the list
    4. all of the above
  10. In the interface ListInterface, the method
    public void add(int newPosition, T newEntry);
    describes which of the following behaviors?
    1. adds a new entry at the specified position in the list
    2. increases the list size by 1
    3. moves entries originally at or above the specified position one position higher
    4. all of the above
  11. In the interface ListInterface, the method
    public void remove(int givenPosition);
    describes which of the following behaviors?
    1. remove the entry at a given position from the list
    2. increases the list size by 1
    3. does not affect any other entries on the list
    4. all of the above
  12. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?
    myList.add(“horse”)
    myList.add(“goat”)
    myList.add(3, “fish”)
    myList.add(1, “dog”)
    myList.add(“cat”)
    1. fish
    2. goat
    3. cat
    4. horse
  13. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?
    myList.add(“horse”)
    myList.add(“goat”)
    myList.add(1, “fish”)
    myList.add(“cat”)
    myList.add(2, “dog”)
    myList.remove(4)
    1. horse
    2. goat
    3. dog
    4. cat
  14. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(4) return after applying the following pseudo code?
    myList.add(“horse”)
    myList.add(“goat”)
    myList.add(1, “fish”)
    myList.add(“cat”)
    myList.remove(1)
    myList.add(2, “dog”)
    1. cat
    2. dog
    3. goat
    4. fish
  15. The public ArrayList() constructor in the Java Class Library ArrayList creates an empty list with an initial capacity of
    1. 10
    2. 0
    3. 100
    4. 1
  16. What does the Java Class Library implementation of the interface list do when an index is out of range?
    1. throw an exception
    2. return null
    3. return false
    4. crash the program
  17. If myList is a declared ADT list and the front of the list is on the left, what does the method getEntry(3) return after applying the following pseudo code?
    myList.add(“horse”)
    myList.add(“goat”)
    myList.add(1, “fish”)
    myList.replace(3, “sheep”)
    myList.add(“cat”)
    myList.remove(1)
    myList.add(2, “dog”)
    1. sheep
    2. dog
    3. horse
    4. cat



Document Information

Document Type:
DOCX
Chapter Number:
10
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 10 - Lists
Author:
Frank M. Carrano

Connected Book

Data Structures with Java 5e Complete Test Bank

By Frank M. Carrano

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party