Exam 15: The Java Collections Framework

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

You need to access values in the opposite order in which they were added (last in, first out), and not randomly. Which collection type should you use?

(Multiple Choice)
4.8/5
(43)

A linear search only requires ____ access.

(Multiple Choice)
4.9/5
(37)

Suppose we have two String objects and treat the characters in each string from beginning to end in the following way: With one string, we push each character on a stack. With the other string, we add each character to a queue. After processing both strings, we then pop one character from the stack and remove one character from the queue, and compare the pair of characters to each other. We do this until the stack and the queue are both empty. What does it mean if all the character pairs match?

(Multiple Choice)
4.8/5
(33)

You need to access values by an integer position. Which collection type should you use?

(Multiple Choice)
4.8/5
(32)

Suppose we create a deque (double-ended queue) data structure. It is basically a queue, with its addLast and removeFirst operations, but we also add the addFirst and removeLast operations. Which of the following is best modeled by the deque data structure?

(Multiple Choice)
4.8/5
(34)

Consider the following code snippet: LinkedList<String> words = new LinkedList<String>(); Words.addFirst("abc"); Words.addLast("def"); Words.addFirst("ghi"); System.out.print(words.removeLast()); System.out.print(words.removeFirst()); System.out.print(words.removeLast()); What will this code print when it is executed?

(Multiple Choice)
4.9/5
(41)

Consider the following code snippet: Queue<String> stringQueue = new LinkedList<String>(); StringQueue.add("ab"); StringQueue.add("abc"); StringQueue.add("a"); While (stringQueue.size() > 0) { System.out.print(stringQueue.remove() + ","); } What output will be produced when this code is executed?

(Multiple Choice)
4.9/5
(41)

Which of the following statements about hash tables is NOT correct?

(Multiple Choice)
4.8/5
(33)

You need to access values in the order in which they were added (first in, first out), and not randomly. Which collection type should you use?

(Multiple Choice)
4.8/5
(29)

To create a TreeSet for a class of objects, the object class must ____.

(Multiple Choice)
4.7/5
(39)

A list is a collection that ____.

(Multiple Choice)
4.8/5
(39)

Which data structure would best be used for keeping track of a growing set of groceries to be purchased at the food market?

(Multiple Choice)
4.9/5
(34)

Consider the following code snippet: LinkedList<String> myLList = new LinkedList<String>(); MyLList.add("Mary"); MyLList.add("John"); MyLList.add("Sue"); ListIterator<String> iterator = myLList.listIterator(); Iterator.next(); Iterator.next(); Iterator.add("Robert"); Iterator.previous(); Iterator.previous(); Iterator.remove(); System.out.println(myLList); What will be printed when this code is executed?

(Multiple Choice)
4.9/5
(35)

Which data structure would best be used for keeping track of bank customers waiting for a teller?

(Multiple Choice)
4.9/5
(42)

Assume you have created a linked list named myList that currently holds some number of String objects. Which of the following statements correctly adds a new element to the beginning of myList?

(Multiple Choice)
4.8/5
(35)

You need to access values in objects by a key that is not part of the object. Which collection type should you use?

(Multiple Choice)
4.9/5
(38)

Assume that you have declared a set named mySet to hold String elements. Which of the following statements will correctly insert an element into mySet?

(Multiple Choice)
4.8/5
(37)

Consider the following code snippet: PriorityQueue<String> stringQueue = new PriorityQueue<String>(); StringQueue.add("ab"); StringQueue.add("abc"); StringQueue.add("a"); While (stringQueue.size() > 0) { System.out.print(stringQueue.remove() + ","); } What output will be produced when this code is executed?

(Multiple Choice)
4.9/5
(39)

Which of the following statements about manipulating objects in a set is correct?

(Multiple Choice)
4.8/5
(32)

Assume you are using a doubly-linked list data structure with many nodes. What is the minimum number of node references that are required to be modified to remove a node from the middle of the list? Consider the neighboring nodes.

(Multiple Choice)
4.7/5
(37)
Showing 61 - 80 of 110
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)