Exam 15: The Java Collections Framework

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

Consider the following code snippet: Stack<String> words1 = new Stack<String>(); ArrayList<String> words3 = new ArrayList<String>(); Words1.push("abc"); Words1.push("def"); Words1.push("ghi"); While (!words1.empty()) { Words3.add(words1.pop()); } Int i = words3.size() - 1; While (i >= 0) { System.out.print(words3.remove(i)); I--; } What will this code print when it is executed?

(Multiple Choice)
4.8/5
(39)

Assume that you have declared a map named myMap to hold String elements with Integer keys. Which of the following statements will correctly insert an element into myMap?

(Multiple Choice)
4.8/5
(33)

Which of the following correctly declares a stack that will hold String elements?

(Multiple Choice)
4.9/5
(42)

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

(Multiple Choice)
4.7/5
(33)

When using a list iterator, on which condition will the IllegalStateException be thrown?

(Multiple Choice)
4.7/5
(37)

Which Java package contains the LinkedList class?

(Multiple Choice)
4.9/5
(41)

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

(Multiple Choice)
4.8/5
(46)

You need to write a program to build and maintain an address book. Since the program must support the possibility of having duplicate names, which data structure would be most appropriate to model this situation?

(Multiple Choice)
5.0/5
(45)

Which of the following algorithms would be efficiently executed using a LinkedList?

(Multiple Choice)
4.8/5
(45)

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

(Multiple Choice)
5.0/5
(34)

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
(39)

Which of the following statements about the LinkedList class is correct?

(Multiple Choice)
4.9/5
(42)

A queue is a collection that ____.

(Multiple Choice)
4.9/5
(30)

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.8/5
(34)

A list is a collection that ____.

(Multiple Choice)
4.9/5
(27)

Consider the following code snippet: Map<String, Integer> scores; If you need to visit the keys in sorted order, which of the following statements will create a structure to support this?

(Multiple Choice)
4.7/5
(33)

Assume that you have declared a map named myMap to hold String elements with Integer keys. Which of the following statements will correctly retrieve the value of an element from myMap by using its key?

(Multiple Choice)
4.8/5
(35)

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

(Multiple Choice)
4.9/5
(28)

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. If a line at the grocery store resembles a deque more than a queue, what is the most likely reason? I the cashier is very fast II the line is very long III the cashier is very slow

(Multiple Choice)
4.7/5
(35)

Which data structure would best be used for finding a path out of a maze?

(Multiple Choice)
4.7/5
(40)
Showing 81 - 100 of 100
close modal

Filters

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