Gaddis Ch.11 Inheritance Test Bank - Test Bank | Python 5e by Gaddis by Tony Gaddis. DOCX document preview.

Gaddis Ch.11 Inheritance Test Bank

Starting Out with Python 5e (Gaddis)

Chapter 11 Inheritance

TRUE/FALSE

1. New attributes and methods may be added to a subclass.

2. One problem with using a UML diagram is that there is no way to indicate inheritance.

3. When a class inherits another class, it is required to use all the data attributes and methods of the superclass.

4. Polymorphism works on any two class methods that have the same name.

5. A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.

6. A subclass may not override any method other than the __init__ method.

7. Each subclass has a method named __init__ that overrides the superclass's __init__ method.

8. In a UML diagram depicting inheritance, you only need to write the name of the subclass.

9. An "is a" relationship exists between a grasshopper and a bumblebee.

10. An "is a" relationship exists between a wrench and a tool.

MULTIPLE CHOICE

1. __________ allows a new class to inherit members of the class it extends.

a.

Encapsulation

b.

Attributes

c.

Methods

d.

Inheritance

2. What gives a program the ability to call the correct method depending on the type of object that is used to call it?

a.

Polymorphism

b.

Inheritance

c.

Encapsulation

d.

Methods

3. What does a subclass inherit from a superclass?

a.

instances and attributes

b.

objects and methods

c.

methods and instances

d.

attributes and methods

4. In a UML diagram, what does the open arrowhead point to?

a.

the superclass

b.

the subclass

c.

the object

d.

a method

5. When there are several classes that have many common data attributes, it is better to write a(n) __________ to hold all the general data.

a.

superclass

b.

subclass

c.

object

d.

method

6. In an inheritance relationship, what is a specialized class called?

a.

a superclass

b.

a subclass

c.

an object

d.

an instance

7. Base classes are also called

a.

superclasses

b.

derived classes

c.

subclasses

d.

class instances

8. What is the relationshop called in which one object is a specialized version of another object?

a.

parent-child

b.

node-to-node

c.

is a

d.

class-subclass

9. __________ has the ability to define a method in a subclass and then define a method with the same name in a superclass.

a.

Inheritance

b.

Encapsulation

c.

Polymorphism

d.

the 'is a' relationship

10. In the following line of code, what is the name of the subclass?

class Rose(Flower):

a.

Rose

b.

Flower

c.

Rose(Flower)

d.

None of these

11. In the following line of code, what is the name of the base class?

class Python(Course):

a.

Python

b.

Course

c.

Python(Course)

d.

None of these

12. Given the following line of code, in a UML diagram, what would the open arrowhead point to?

class Celery(Vegetable):

a.

Celery

b.

Vegetable

c.

class

d.

Celery(Vegetable)

13. Of the two classes, Cherry and Flavor, which would most likely be the subclass?

a.

Cherry

b.

Flavor

c.

either one

d.

neither; these are inappropriate class or subclass names

14. Which method can you use to determine whether an object is an instance of a class?

a.

isinstance

b.

isclass

c.

isobject

d.

issubclass

15. Which of the following is the correct syntax for defining a class, table, which inherits from the furniture class?

a.

class furniture[table]:

b.

class table.furniture:

c.

class furniture(table):

d.

class table(furniture):

16. Given the following beginning of a class definition for a superclass named clock, how many accessor and mutator methods will be needed to complete the class definition?

class clock:

def __init__(self, shape, color, price):

self._shape = shape

self.color = color

self.price = price

a.

1 mutator, 1 accessor

b.

3 mutator, 4 accessor

c.

3 mutator, 3 accessor

d.

4 mutator, 5 accessor

COMPLETION

1. __________ allows subclasses to have methods with the same names as methods in their superclasses.

2. The __________ function determines whether or not an object is an instance of a specific class or an instance of a subclass of that class.

3. A subclass is also called a(n) __________ class.

4. A superclass is also called a(n) __________ class.

5. When a subclass method has the same name as a superclass method, the subclass method __________ the superclass method.

6. In an inheritance relationship, the extended class is called the __________.

7. New attributes and methods may be added to a subclass which makes it a(n) __________ version of the superclass.

8. In an inheritance relationship, a minivan can be thought of as a(n) ___________ of the vehicles class.

9. The term ___________ refers to an object's ability to take different forms.

10. In a UML diagram, a line with an open arrowhead from a subclass to a superclass indicates ___________.

Document Information

Document Type:
DOCX
Chapter Number:
11
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 11 Inheritance
Author:
Tony Gaddis

Connected Book

Test Bank | Python 5e by Gaddis

By Tony Gaddis

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party