Exam 15: The Java Collections Framework

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

Consider the code snippet shown below. Assume that employeeNames is an instance of type LinkedList<String>. For (String name : employeeNames) { // Do something with name here } Which element(s) of employeeNames does this loop process?

Free
(Multiple Choice)
4.8/5
(39)
Correct Answer:
Verified

B

Complete the following code, which is intended to print out all key/value pairs in a map named myMap that contains String data for student IDs and names: Map<String, String> myMap = new HashMap<String, String>(); ) . . _______________________________ For (String aKey : mapKeySet) { String name = myMap.get(aKey); System.out.println("ID: " + aKey + "->" + name); }

Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
Verified

D

You need to write a program to simulate the effect of adding an additional cashier in a supermarket to reduce the length of time customers must wait to check out. Which data structure would be most appropriate to simulate the waiting customers?

Free
(Multiple Choice)
5.0/5
(30)
Correct Answer:
Verified

C

You want to enumerate all of the keys in a map named myMap whose keys are type String. Which of the following statements will allow you to do this?

(Multiple Choice)
4.9/5
(44)

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

(Multiple Choice)
4.7/5
(29)

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

What is included in a linked list node? I a reference to its neighboring nodes II an array reference III a data element

(Multiple Choice)
4.9/5
(42)

A linked list ____ encapsulates a position anywhere inside the linked list.

(Multiple Choice)
4.9/5
(32)

A(n) ____ is a data structure used for collecting a sequence of objects that allows efficient addition and removal of already-located elements in the middle of the sequence.

(Multiple Choice)
4.9/5
(47)

Print jobs submitted to a printer would probably be stored in which type of data structure?

(Multiple Choice)
4.8/5
(41)

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

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

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

(Multiple Choice)
4.9/5
(43)

Assume that you have declared a stack named myStack to hold String elements. Which of the following statements will correctly retrieve the top element from myStack without removing it?

(Multiple Choice)
4.9/5
(37)

A binary search requires ____ access.

(Multiple Choice)
4.7/5
(39)

Which data structure would best be used for storing a set of numbers and sorting them in ascending order?

(Multiple Choice)
4.8/5
(39)

We might choose to use a linked list over an array list when we will not require frequent ____. I random access II inserting new elements III removing of elements

(Multiple Choice)
4.8/5
(49)

The nodes of a(n) ____ linked list class store two links: one to the next element and one to the previous one.

(Multiple Choice)
4.7/5
(34)

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

(Multiple Choice)
4.9/5
(37)

A collection without an intrinsic order is called a ____.

(Multiple Choice)
4.7/5
(36)
Showing 1 - 20 of 100
close modal

Filters

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