Filters
Question type

Study Flashcards

A set of methods that could be used on other data structures besides the one they were created for could be used in a general abstract class.

A) True
B) False

Correct Answer

verifed

verified

What is the syntax for the calling the __init__ method in the ArrayBag class from the ArraySortedBag class?


A) self.init(ArrayBag, sourceCollection)
B) ArrayBag.self(__init__, sourceCollection)
C) ArrayBag.__init__(self, sourceCollection)
D) __init__.ArrayBag(self, sourceCollection)

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

Correct Answer

verifed

verified

By using inheritance to create new classes, you increase code redundancy.

A) True
B) False

Correct Answer

verifed

verified

In the constructor for the ArrayBag class shown below, what is the missing code? Def __init__(self, sourceCollection = None) : < missing code > AbstractBag.__init__(self, sourceCollection)


A) items.add(self)
B) self.items = Array(ArrayBag.DEFAULT_CAPACITY)
C) self.items = ArrayBag.add(sourceCollection)
D) add.items(self, sourceCollection)

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

Correct Answer

verifed

verified

The __init__ method in the parent class is automatically called by a subclass of the parent class.

A) True
B) False

Correct Answer

verifed

verified

What would be the purpose of creating a more general abstract class called AbstractCollection ?


A) to group methods used by a single subclass
B) to hide the details of the methods used in your abstract classes
C) to create objects from a client application
D) to group methods that can be used for other types of collections

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

Correct Answer

verifed

verified

When considering the ArrayBag class and the ArraySortedBag class, which of the following is true?


A) the ArraySortedBag class is the parent of the ArrayBag class
B) the ArraySortedBag class is a subclass of ArrayBag
C) the ArrayBag class is a subclass of ArraySortedBag
D) the ArrayBag class is the child class of ArraySortedBag

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

Correct Answer

verifed

verified

What is a class called when the purpose of it is to eliminate redundant methods in other classes?


A) concrete class
B) abstract class
C) subclass
D) child class

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

Correct Answer

verifed

verified

When looking at a hierarchy of abstract classes, the classes trend from the more specific to the more general going from the top to the bottom of the hierarchy.

A) True
B) False

Correct Answer

verifed

verified

What is the root class of Python's built-in class hierarchy?


A) self
B) list
C) dict
D) object

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

Correct Answer

verifed

verified

If a programmer calls the next function on an iterator object and there is no current item in the sequence, the next function returns the Null item.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is true about the three bag classes (LinkedBag, ArrayBag, ArraySortedBag) ?


A) they are abstract classes
B) they implement the bag interface
C) the are all superclasses
D) LinkedBag is a subclass of ArraySortedBag

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

Correct Answer

verifed

verified

When calling the __init__ method from a subclass, you need to include the self argument.

A) True
B) False

Correct Answer

verifed

verified

An abstract class is always used to create objects in client applications.

A) True
B) False

Correct Answer

verifed

verified

The root class of the Python hierarchy is called object .

A) True
B) False

Correct Answer

verifed

verified

An abstract class captures the common features and behavior of a set of related classes.

A) True
B) False

Correct Answer

verifed

verified

When you use inheritance to customize a class, the existing and new class have identical behavior.

A) True
B) False

Correct Answer

verifed

verified

Under which circumstance can an instance variable be moved to an abstract class?


A) when it refers to the same type of data structure
B) when it is unique to a particular concrete class
C) when different data structure types are referenced by the variable
D) when it directly modifies the underlying data structure

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

Correct Answer

verifed

verified

In the ArraySortedBag class, why must the self argument be passed to the __init__ method of ArrayBag?


A) to ensure the add method in ArraySortedBag is called if a source collection is specified
B) to ensure that ArraySortedBag calls the correct __init__ method
C) to ensure that ArrayBag calls its own __init__ method
D) to ensure the add method in ArrayBag is called if a source collection is specified

E) None of the above
F) All of the above

Correct Answer

verifed

verified

A primary purpose of using inheritance is to eliminate redundant code.

A) True
B) False

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer