Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 11 pts Which of the following is NOT one of the 3 main categories of collections? In other words, which of these objects does

Question 11 pts

Which of the following is NOT one of the 3 main categories of collections? In other words, which of these objects does not, itself, represent a collection of items?

Iterator
List
Map
Set

Flag this Question

Question 21 pts

Which of the following is true about Lists and Sets?

Lists are indexed; Sets are not.
Lists may contain duplicate items; Sets do not.
Both of the above.
None of the above.

Flag this Question

Question 31 pts

Which of the following may be used to examine every item in the List myList?

Option A:

for( int i = 0; i < myList.size( ); i++ )  System.out.println( myList.get( i ) ); 

Option B:

for( String s : myList )  System.out.println( s ); 

Option C:

Iterator it = myList.iterator( );  while( it.hasNext( ) )  System.out.println( it.next( ) );
Option A only.
Option B only.
Option C only.
Either A or B, but not C.
Any of the above.
None of the above.

Flag this Question

Question 41 pts

Which of the following may be used to examine every item in the Set mySet?

Option A:

for( int i = 0; i < mySet.size( ); i++ )  System.out.println( mySet.get( i ) ); 

Option B:

for( String s : mySet )  System.out.println( s ); 

Option C:

Iterator it = mySet.iterator( );  while( it.hasNext( ) )  System.out.println( it.next( ) );
Option A only.
Option B only.
Option C only.
Either B or C, but not A.
A, B or C may be used.
None of the above.

Flag this Question

Question 51 pts

Every key in a Map must be unique. What happens when a Map receives a 'put' message specifying a key that is already used in the Map?

A DuplicateKeyException is thrown.
The map entry for the key is updated -- its associated value is replaced by the new value specified, and the old value is returned by the 'put' method.
The map entry for the key is updated -- its associated value is replaced by the new value specified, and null is returned by the 'put' method.
The map entry for the key is updated -- the new value specified is added to the list of values associated with the key.
No change is made to the Map, and the 'put' method returns null.

Flag this Question

Question 61 pts

Which of the following could be an "expensive" operation (an operation that takes a long time to complete) in an ArrayList?

adding a new item at the end of the list when size( ) is less than capacity
adding a new item at the beginning of the list
using get(itemNumber) to examine a list item in the middle of the list
iterating through the list

Flag this Question

Question 71 pts

Which of the following could be an "expensive" operation in the SimpleLinkedList class we discussed?

adding a new item at the end of the list
adding a new item at the beginning of the list
using get(itemNumber) to examine a list item in the middle of the list
calling 'next()' using an iterator provided by the list

Flag this Question

Question 81 pts

What will be the contents of myList, in the correct order, after the following sequence of operations? (Assume all operations are supported by the list implementation used.)

List myList = ... // create new, empty list  myList.add( "red" );  myList.add( "green" );  myList.add( "red" );  myList.add( 1, "black" );
[ "red", "green", "red", "black" ]
[ "black", "green", "red" ]
[ "red", "black", "green", "red" ]
[ "black", "red", "green" ]
[ "red", "black", "red" ]

Flag this Question

Question 91 pts

What will be the contents of mySet, regardless of order, after the following sequence of operations? (Assume all operations are supported by the set implementation used.)

Set mySet = ... // create new, empty set  mySet.add( "red" );  mySet.add( "green" );  mySet.add( "red" );  mySet.add( "black" );
[ "red", "green", "red", "black" ]
[ "black", "green", "red" ]
[ "green", "red" ]
[ "black" ]
[ "green", "black" ]

Flag this Question

Question 101 pts

What will be the contents of myMap, regardless of order, after the following sequence of operations? (Assume all operations are supported by the map implementation used.) Answers are shown as key=value pairs.

Map myMap = ... // create new, empty map  myMap.put( "red", "green" );  myMap.put( "orange", "blue" );  myMap.put( "red", "yellow" );  myMap.put( "blue", "black" );
[ "red"="green", "orange"="blue", "red"="yellow", "blue"="black" ]
[ "orange"="blue", "red"="yellow" ]
[ "red"="green", "orange"="blue" ]
[ "red"="yellow", "blue"="black" ]
[ "orange"="blue", "red"="yellow", "blue"="black" ]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Analytics Systems Engineering Cybersecurity Project Management

Authors: Christopher Greco

1st Edition

168392648X, 978-1683926481

More Books

Students also viewed these Databases questions

Question

15. Give examples of variations in contextual rules.

Answered: 1 week ago

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago