Exam 6: Inheritance and Abstract Classes
Exam 1: Basic Python Programming51 Questions
Exam 2: An Overview of Collections50 Questions
Exam 3: Searching, Sorting, and Complexity Analysis50 Questions
Exam 4: Arrays and Linked Structures50 Questions
Exam 5: Interfaces, Implementations, and Polymorphism50 Questions
Exam 6: Inheritance and Abstract Classes50 Questions
Exam 7: Stacks50 Questions
Exam 8: Queues50 Questions
Exam 9: Lists50 Questions
Exam 10: Trees50 Questions
Exam 11: Sets and Dictionaries50 Questions
Exam 12: Graphs50 Questions
Select questions type
Which operator, when used with two bags, causes Python to run the __add__ method?
Free
(Multiple Choice)
4.8/5
(32)
Correct Answer:
C
The following code is part of the add method in the ArraySortedBag class. What is the missing code? if self.isEmpty() or item >= self.items[len(self) - 1]:
< missing code >
Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
C
A concrete class is often a subclass of an abstract class and is used to create objects in client applications.
Free
(True/False)
4.9/5
(34)
Correct Answer:
True
When a programmer calls the iter function on a collection, the collection's iterator object is returned.
(True/False)
4.7/5
(32)
To begin creating a subclass, copy the parent class's file and delete the methods that will not change.
(True/False)
4.9/5
(37)
To ensure that inheritance occurs, you need to place the name of the subclass in parentheses of the class header.
(True/False)
4.8/5
(34)
The __eq__ method in the AbstractCollection class compares pairs of items in two collections.
(True/False)
4.8/5
(40)
In the following code for the __add__ method in the ArraySortedBag class, what is the missing code? def __add__(self, other):
Result = ArraySortedBag(self)
For item in other:
< missing code >
Return result
(Multiple Choice)
4.8/5
(33)
The implementations of the __str__ and __eq__ methods in the AbstractCollection class can be used in both unordered and linear collections.
(True/False)
4.9/5
(37)
Programming languages such as Java include a collection framework more extensive than that of Python.
(True/False)
4.8/5
(38)
An instance variable is considered redundant if two different classes use it and it refers to a different type of data structure in each class.
(True/False)
4.7/5
(46)
In the following code for the ArrayBag class __contains__ method, what is the missing code?
Def __contains__(self, item):
Left = 0
Right = len(self) - 1
While left <= right:
MidPoint = (left + right) // 2
If self.items[midPoint] == item:
Return True
Elif self.items[midPoint] > item:
Right = midPoint - 1
Else:
< missing code >
Return False
(Multiple Choice)
4.9/5
(32)
The easiest way to take advantage of inheritance is to use it to customize an existing class.
(True/False)
4.9/5
(37)
Which of the following is true about the sorted bag collection compared to the regular bag collection?
(Multiple Choice)
4.8/5
(28)
Which of the following is NOT a step in using inheritance to create a subclass?
(Multiple Choice)
4.8/5
(32)
When you finish writing the abstract class, what must the subclasses do to use it?
(Multiple Choice)
4.9/5
(42)
To distinguish a method in the parent class from a method with the same name in a subclass, prefix the method name with self .
(True/False)
4.8/5
(34)
What method is called when the in operator is used on a sorted bag?
(Multiple Choice)
4.9/5
(34)
In the case of the AbstractCollection class, which of the following methods should NOT be included in this class?
(Multiple Choice)
4.8/5
(35)
When a class is customized using inheritance, the two classes should have a similar interface.
(True/False)
4.8/5
(45)
Showing 1 - 20 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)