Chapter 11 Python

Ace your homework & exams now with Quizwiz!

what is the relationship called in which one object is a specialized version of another object?

is a

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

isinstance

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

polymorphism

In the following line of code, what is the name of the subclass? class Rose(Flower):

rose

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

inheritance

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

3 mutator, 3 accessor

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

Pollymorphism

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

a subclass

what does a subclass inherit from a superclass?

atrributes and methods

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

cherry

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

class table(furniture):

in the following line of code, what is the name of the base class? class Python(Course):

course

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

false

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

false

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

false

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

false

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

false lol the whole point of the diagram is to show inheritance

An "is a" relashonship exists between a grasshopper and a bumblebee

fasle

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

superclass

base classes are also called

superclasses

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

the superclass

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

true

New attributes and methods may be added to a subclass.

true

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

true

Given the following line of code, in a UML diagram, what would the open arrowhead point to? class Celery(Vegetable):

vegetable


Related study sets

Chapter 12: Planning, Implementing, and Evaluating Community/Public Health Programs

View Set

Lacharity: Chapter 14: Endocrine

View Set

Computer Science Review (Basic Python)

View Set

Accounting multiple choice chapter 10

View Set

ITN 260 Module 15 Review, ITN 260 Module 13 Review, ITN 260 Module 12 Review, Module 14, Quiz: Module 12 Authentication, Quiz 14, Quiz 11

View Set