Question: QUESTION 11 Consider the following code snippet: Stack stringStack = new Stack (); stringStack.push(ab); stringStack.push(abc); stringStack.push(a); while (stringStack.size() > 0) { System.out.print(stringStack.pop() + ,); }

QUESTION 11

Consider the following code snippet:

Stack stringStack = new Stack(); 
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?

ab,abc,a,

a,abc,ab,

a,ab,abc,

abc,ab,a,

QUESTION 12

A collection without an intrinsic order is called a ____.

list

stack

set

queue

QUESTION 13

The term ____ is used in computer science to describe an access pattern in which the elements are accessed in arbitrary order.

sequential access

random access

sorted access

arbitrary access

QUESTION 14

Consider the code snippet shown below. Assume that employeeNames is an instance of type LinkedList.

for (String name : employeeNames) 
{ 
 // Do something with name here 
} 

Which element(s) of employeeNames does this loop process?

no elements

all elements

elements meeting a condition

the most recently added elements

QUESTION 15

What type of access does a LinkedList provide for its elements?

sequential

semi-random

random

sorted

QUESTION 16

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 myMap = new HashMap(); 
. . . 
_______________________________ 
for (String aKey : mapKeySet) 
{ 
 String name = myMap.get(aKey); 
 System.out.println("ID: " + aKey + "->" + name); 
} 

Map mapKeySet = myMap.keySet();

Set mapKeySet = myMap.keySet();

Set mapKeySet = myMap.getKeySet();

Set mapKeySet = myMap.keySet();

QUESTION 17

Which method is NOT part of the ListIterator generic class?

hasNext

hasMore

hasPrevious

add

1 points

QUESTION 18

What can a generic class be parameterized for?

properties

iterators

type

methods

QUESTION 19

Consider the following code snippet:

LinkedList myLList = new LinkedList(); 
myLList.add("Mary"); 
myLList.add("John"); 
myLList.add("Sue"); 
ListIterator 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?

[Mary, John, Robert, Sue]

[Mary, John, Sue]

[Mary, Robert, Sue]

[John, Robert, Sue]

QUESTION 20

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?

Map

Hashtable

Stack

Queue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!