Filters
Question type

Study Flashcards

What is it called when the contents of two bags are combined into a third bag?


A) iteration
B) appending
C) concatenation
D) reduction

E) C) and D)
F) All of the above

Correct Answer

verifed

verified

Once the designer of a collection class has obtained its interface, the implementation of the class includes completing code for the methods.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is a visual aid to help catalog resources in your software toolbox?


A) docstring
B) method mapper
C) unit modeler
D) class diagram

E) C) and D)
F) A) and B)

Correct Answer

verifed

verified

Software bags can grow as more items are added, or they can shrink as items are removed.

A) True
B) False

Correct Answer

verifed

verified

An interface's documentation gives you enough information to know how to use or call a method and what to expect it to accomplish and return.

A) True
B) False

Correct Answer

verifed

verified

When defining the Bag class, the __init__ operation is the constructor for the class.

A) True
B) False

Correct Answer

verifed

verified

The running times of the operations of ArrayBag and LinkedBag are similar.

A) True
B) False

Correct Answer

verifed

verified

Whenever you need to use the logical size of the bag within a class definition, run len(self) instead of referring directly to the instance variable self.size .

A) True
B) False

Correct Answer

verifed

verified

In the ArrayBag class, why must the ArrayBag object track its logical size in a separate instance variable?


A) because the physical size is always smaller than the logical size
B) because the initial size of the object can't be changed
C) because the logical size will likely differ from the array's capacity
D) because the array size and the logical size are identical

E) None of the above
F) B) and D)

Correct Answer

verifed

verified

What word is best defined as the use of common names for operations on different types of collections?


A) anachronism
B) polymorphism
C) concatenation
D) modularization

E) A) and D)
F) B) and C)

Correct Answer

verifed

verified

You should always try to hide the implementing data structures behind a wall of method calls on the object being implemented.

A) True
B) False

Correct Answer

verifed

verified

Why won't some of the ArrayBag methods require changes when implementing the LinkedBag class?


A) because the methods don't use the self variable
B) because the ArrayBag class is based on lists
C) because the LinkedBag object is not iterable
D) because the methods don't directly access the array variable

E) C) and D)
F) A) and C)

Correct Answer

verifed

verified

The __iter__ method is identical in the ArrayBag and LinkedBag classes.

A) True
B) False

Correct Answer

verifed

verified

The statement in the ArrayBag constructor to copy an item from a source collection to a new ArrayBag object is self.init(item) .

A) True
B) False

Correct Answer

verifed

verified

In the ArrayBag class, what function does the __str__ method use to generate a sequence of strings from a bag?


A) count
B) len
C) add
D) map

E) B) and D)
F) None of the above

Correct Answer

verifed

verified

The __iter__ method uses a yield statement to send each item to the calling for loop.

A) True
B) False

Correct Answer

verifed

verified

In the Bag class defined in the chapter, what is one of the purposes of the sourceCollection argument in the __init__ method?


A) to create a bag with the contents of another collection
B) to delete the contents of an existing collection
C) to define source code for the method
D) to add data to an existing bag collection

E) B) and C)
F) All of the above

Correct Answer

verifed

verified

A bag is a type of ordered collection.

A) True
B) False

Correct Answer

verifed

verified

The clear method empties a bag.

A) True
B) False

Correct Answer

verifed

verified

When used with a bag object, the in operator returns an integer value.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer