Starting Out with Python, 3e Ch 11

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Subclasses are also called ______

derived classes

You show inheritance in a UML diagram by _______ from the subclass to the superclass.

drawing a line with an open arrowhead

_______ allows subclasses to have methods with the same names as methods in their superclasses. It gives the ability for a program to call the correct method depending on the type of object that is used to call it.

Polymorphism

A subclass can have a method with the same name as a method in the superclass. T or F

True

Polymorphism allows you to write methods in a subclass that have the same name as methods in the superclass. T or F

True

You cannot use the isinstance function to determine whether an object is an instance of a subclass of a class. T or F

True

What is an overridden method?

When a subclass method has the same name as a superclass method, it is often said that the subclass method overrides the superclass method.

When one object is a specialized version of another object, there is an " is a" relationship between them.

When an "is a" relationship exists between objects, it means that the specialized object has all of the characteristics of the general object, plus additional characteristics that make it special.

What does it mean to say there is an "is a" relationship between two objects?

When one object is a specialized version of another object, there is an "is a" relationship between them. The specialized object " is a" version of the general object.

Look at the fo llowing code, which is the first line of a class definition. What is the name of the superclass? What is the name of the subclass? class Canary(Bird}:

Bird is the superclass Canary is the subclass.

It is not possible to call a superclass's __ init __ method from a subclass's __ init __ method. T or F

False

Only the __ init __ method can be overridden. T or F

False

Look at the following class definition. What is the name of the superclass? What is the name of the subclass? class Tiger(Felis):

Felis is the superclass Tiger is the subclass

______ allows a new class to extend an existing class. The new class inherits the members of the class it extends.

Inheritance

What does a subclass inherit from its superclass?

It inherits all the superclass's attributes.

Suppose a program uses two classes: Airplane and JumboJet. Which of these would most likely be the subclass? a. Airplane b. JumboJet c. Both d. Neither

JumboJet

Superclasses are also called ______

base classes

Inheritance involves a superclass and a subclass. The superclass is the ______ and the subclass is the _______.

general class specialized class

In object-oriented programming, ______ is used to create an "is a" relationship among classes.

inheritance

We can prevent an AttributeError exception from occurring by using the built-in function ______. You can use the ________ function to determine whether an object is an instance of a specific class, or a subclass of that class.

isinstance

This characteristic of object-oriented programming allows the correct version of an overridden method to be called when an instance of a subclass is used to call it. a. polymorphism b. inheritance c. generali zation d. specialization

polymorphism

In an inheritance relationship, the _____ is the specialized class. a. superclass b. master class c. subclass d. parent class

subclass

In an inheritance relationship, the _____ is the general class. a. subclass b. superclass c. slave class d. child class

superclass

In this section we discussed superclasses and subclasses. Which is the general class, and which is the specialized class?

superclass is a general class subclass is a specialized class

You can use this to determine whether an object is an instance of a class. a. the in operator b. the is_object_of function c. the isinstance function d. the error messages that are displayed when a program crashes

the isinstance function


संबंधित स्टडी सेट्स

Adaptive Quizzing - Integumentary System

View Set

Chapter 4: Health assessment Prep U

View Set

Primerica Life & Health Insurance (multiple choice mostly)

View Set