Deck 11: Inheritance
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/36
Play
Full screen (f)
Deck 11: Inheritance
1
Each subclass has a method named __init__ that overrides the superclass's __init__ method.
True
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
A) Polymorphism
B) Inheritance
C) Encapsulation
D) Methods
A
3
An "is a" relationship exists between a wrench and a tool.
True
4
New attributes and methods may be added to a subclass.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
5
In a UML diagram depicting inheritance,you only need to write the name of the subclass.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
6
When a class inherits another class,it is required to use all the data attributes and methods of the superclass.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
7
An "is a" relationship exists between a grasshopper and a bumblebee.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
8
One problem with using a UML diagram is that there is no way to indicate inheritance.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
9
In an inheritance relationship,what is a specialized class called?
A) a superclass
B) a subclass
C) an object
D) an instance
A) a superclass
B) a subclass
C) an object
D) an instance
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
10
Base classes are also called
A) superclasses
B) derived classes
C) subclasses
D) class instances
A) superclasses
B) derived classes
C) subclasses
D) class instances
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
11
What does a subclass inherit from a superclass?
A) instances and attributes
B) objects and methods
C) methods and instances
D) attributes and methods
A) instances and attributes
B) objects and methods
C) methods and instances
D) attributes and methods
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
12
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
A) superclass
B) subclass
C) object
D) method
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
13
Polymorphism works on any two class methods that have the same name.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
14
A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
15
__________ allows a new class to inherit members of the class it extends.
A) Encapsulation
B) Attributes
C) Methods
D) Inheritance
A) Encapsulation
B) Attributes
C) Methods
D) Inheritance
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
16
__________ 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
A) Inheritance
B) Encapsulation
C) Polymorphism
D) the 'is a' relationship
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
17
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
Class Rose(Flower):
A) Rose
B) Flower
C) Rose(Flower)
D) None of these
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
18
In a UML diagram,what does the open arrowhead point to?
A) the superclass
B) the subclass
C) the object
D) a method
A) the superclass
B) the subclass
C) the object
D) a method
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
19
A subclass may not override any method other than the __init__ method.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
20
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
A) parent-child
B) node-to-node
C) is a
D) class-subclass
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
21
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):
A) class furniture[table]:
B) class table.furniture:
C) class furniture(table):
D) class table(furniture):
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
22
A superclass is also called a(n)__________ class.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
23
In a UML diagram,a line with an open arrowhead from a subclass to a superclass indicates ___________.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
24
Which method can you use to determine whether an object is an instance of a class?
A) isinstance
B) isclass
C) isobject
D) issubclass
A) isinstance
B) isclass
C) isobject
D) issubclass
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
25
In an inheritance relationship,a minivan can be thought of as a(n)___________ of the vehicles class.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
26
The term ___________ refers to an object's ability to take different forms.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
27
New attributes and methods may be added to a subclass which makes it a(n)__________ version of the superclass.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
28
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
A) Cherry
B) Flavor
C) either one
D) neither; these are inappropriate class or subclass names
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
29
When a subclass method has the same name as a superclass method,the subclass method __________ the superclass method.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
30
The __________ function determines whether or not an object is an instance of a specific class or an instance of a subclass of that class.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
31
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?

A) 1 mutator, 1 accessor
B) 3 mutator, 4 accessor
C) 3 mutator, 3 accessor
D) 4 mutator, 5 accessor

A) 1 mutator, 1 accessor
B) 3 mutator, 4 accessor
C) 3 mutator, 3 accessor
D) 4 mutator, 5 accessor
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
32
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)
Class Celery(Vegetable):
A) Celery
B) Vegetable
C) class
D) Celery(Vegetable)
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
33
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
Class Python(Course):
A) Python
B) Course
C) Python(Course)
D) None of these
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
34
In an inheritance relationship,the extended class is called the __________.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
35
A subclass is also called a(n)__________ class.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck
36
__________ allows subclasses to have methods with the same names as methods in their superclasses.
Unlock Deck
Unlock for access to all 36 flashcards in this deck.
Unlock Deck
k this deck