Exam 15: The Java Collections Framework

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

A collection that allows items to be added only at one end and removed only at the other end is called a ____.

(Multiple Choice)
4.9/5
(34)

Assume that you have declared a queue named myQueue to hold String elements. Which of the following statements will correctly remove an element from myQueue?

(Multiple Choice)
4.7/5
(35)

You need to access values using a key, and the keys must be sorted. Which collection type should you use?

(Multiple Choice)
4.9/5
(35)

Consider the code snippet shown below: Stack<String> words1 = new Stack<String>(); Stack<String> words2 = new Stack<String>(); Words1.push("abc"); Words1.push("def"); Words1.push("ghi"); While (!words1.empty()) { Words2.push(words1.pop()); } While (!words2.empty()) { System.out.print(words2.pop()); } What will be printed when this code is executed?

(Multiple Choice)
4.8/5
(46)

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

(Multiple Choice)
4.8/5
(34)

Assume you have created a linked list name myList that currently holds some number of String objects. Which of the following statements correctly removes an element from the end of myList?

(Multiple Choice)
4.7/5
(37)

A collection that allows speedy insertion and removal of already-located elements in the middle of it is called a ____.

(Multiple Choice)
4.9/5
(36)

Which of the following statements about stacks is correct?

(Multiple Choice)
5.0/5
(34)

A linear search only requires ____ access.

(Multiple Choice)
4.9/5
(38)

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

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

(Multiple Choice)
4.7/5
(50)

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

(Multiple Choice)
4.8/5
(35)

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

A stack is a collection that ____.

(Multiple Choice)
4.9/5
(29)

Consider the following code snippet: Stack<String> stringStack = new Stack<String>(); StringStack.push("ab"); StringStack.push("abc"); StringStack.push("a"); While (stringStack.size() > 0) { System.out.print(stringStack.pop() + ","); } What output will be produced when this code is executed?

(Multiple Choice)
4.9/5
(41)

Which nodes need to be updated when we insert a new node to become the fourth node from the beginning of a doubly-linked list?

(Multiple Choice)
4.7/5
(29)

You need to write a program to build and maintain a catalog of college courses that are associated with specific majors. Which data structure would be most appropriate to model this situation?

(Multiple Choice)
4.8/5
(43)

Which of the following statements about sets is correct?

(Multiple Choice)
4.8/5
(43)

Which of the following statements about a priority queue structure is correct?

(Multiple Choice)
4.7/5
(43)

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
(42)
Showing 21 - 40 of 100
close modal

Filters

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