Question: Data Structures QUESTION 1 An abstract data type is not necessarily a collection. True False 1 points QUESTION 2 A collection is not necessarily an

Data Structures

QUESTION 1

An abstract data type is not necessarily a collection.

True

False

1 points

QUESTION 2

A collection is not necessarily an abstract data type.

True

False

1 points

QUESTION 3

Entries of a bag can belong to classes related by inheritance.

True

False

1 points

QUESTION 4

All entries of a bag must have the same data type or a subtype of that data type.

True

False

1 points

QUESTION 5

By declaring a data type to be a BagInterface, we can replace the bag class with another class that implements the BagInterface.

True

False

1 points

QUESTION 6

A method can change the state of an object passed to it as an argument.

True

False

1 points

QUESTION 7

A set is a special kind of bag.

True

False

1 points

QUESTION 8

A language-independent specification for a group of values and operations on those values is called a/an:

abstract data type

data structure

collection

primitive

1 points

QUESTION 9

An implementation of an ADT with a programming language is called a/an:

data structure

abstract data type

collection

primitive

1 points

QUESTION 10

An object that groups other objects and provides services to its clients is called a/an:

collection

abstract data type

data structure

primitive

1 points

QUESTION 11

Which of the following is not true with regard to bags?

objects are in a specific order

can contain duplicate items

is an abstract data type

is a kind of collection in Java

1 points

QUESTION 12

Which behavior is not represented in a bag?

reorder the bag

report the number of items in the bag

report if the bag is empty

add an item to the bag

1 points

QUESTION 13

Why would the add method return false?

when the addition of a new item was not successful

when there was a duplicate of the entry already in the bag

when there was not a duplicate of the entry already in the bag

when addition of a new item was successful

1 points

QUESTION 14

Which behaviors do not change the contents of a bag?

add()

clear()

remove()

none of the above

1 points

QUESTION 15

Which behaviors change the contents of a bag?

clear()

remove()

add()

all of the above

1 points

QUESTION 16

When using abstraction as a design principle you should focus on:

what you want to do with the data

how the data is stored

how the data is manipulated

all of the above

1 points

QUESTION 17

Which of the following is a special kind of bag that does not allow duplicate entries?

set

collection

extended bag

super bag

1 points

QUESTION 18

When adding an item to a bag, which of the following statements are true?

You cannot specify the position of the item in the bag.

You can specify the item will be placed as the first in the bag.

You can specify the item will be placed as the last in the bag.

None of the above.

1 points

QUESTION 19

To accommodate entries of any class, the bag methods use ______ .

a generic type

an inherited type

a sub class

all of the above

1 points

QUESTION 20

Which behavior(s) change the contents of a bag?

remove()

getCurrentSize()

isEmpty()

getFrequencyOf()

1 points

QUESTION 21

Which behavior(s) change the contents of a bag?

add()

getFrequencyOf()

contains()

toArray()

1 points

QUESTION 22

Which behaviors leave the contents of a bag unaltered?

contains()

remove()

clear()

add()

1 points

QUESTION 23

Which behavior(s) leave the contents of a bag unaltered?

toArray()

getFrequencyOf()

isEmpty()

all of the above

1 points

QUESTION 24

Which of the following are good reasons to write Java statements that use your bag ADT before the implementation is done?

it helps confirm the design

it helps check the suitability of the specification

it helps check your understanding of the specification

all of the above

1 points

QUESTION 25

Which of the following would be suitable items to store in a bag?

marbles

coins

student roster

all of the above

1 points

QUESTION 26

You wish to keep track of the distribution of words in a document, for example, how many times the word apple appears. You store each word in the document in a bag. Why is a bag a potentially good solution?

the order of the words is unimportant

the words in the document are not unique

getFrequencyOf() is a useful behavior for determining the word distribution

all of the above

1 points

QUESTION 27

For which of the following would a bag implementation be suitable?

a shopping cart

a vending machine

a postage stamp collection

all of the above

1 points

QUESTION 28

Which behavior is not specified in the bag ADT?

sort()

contains()

clear()

remove()

1 points

QUESTION 29

Which bag behavior is not useful or relevant for a set?

getFrequencyOf()

add()

remove()

contains()

1 points

QUESTION 30

Which bag behaviors would need modified when implementing a set?

add()

clear()

contains()

toArray()

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!