Deck 11: Inheritance

Full screen (f)
exit full mode
Question
Of the two classes Cola and Soda, which would most likely be the subclass?

A) Cola
B) Soda
C) Both
D) Either
Use Space or
up arrow
down arrow
to flip the card.
Question
In the following line of code, what is the name of the base class?
Class Male(Human):

A) Male
B) Human
C) Either
D) Incorrect code
Question
An 'is a' relationship exists between a grasshopper and a bumblebee.
Question
What does a subclass inherit from a superclass?

A) Instances and attributes
B) Data and methods
C) Methods and instances
D) Attributes and methods
Question
Base classes are also called _____.

A) superclasses
B) derived
C) subclasses
D) classes
Question
Each subclass has a method named __init__ that overrides the superclass's __init__.
Question
New attributes and methods may be added to a subclass.
Question
Examine the following piece of code:
Class Potato (Vegetable):
In a UML diagram, what would the open arrowhead point to?

A) Potato
B) Vegetable
C) class
D) Potato(Vegetable)
Question
When a class inherits another class, it is required to use all the data attributes and methods of the superclass.
Question
It is not possible to indicate inheritance in a UML diagram.
Question
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
Question
In the following line of code, what is the name of the subclass?
Class Rose(Flower):

A) Rose
B) Flower
C) Either
D) Incorrect code
Question
In a UML diagram, what does the open arrowhead point to?

A) Superclass
B) Subclass
C) Object
D) Method
Question
_____ allows a new class to inherit the members of the class it extends.

A) Encapsulation
B) Domain
C) Methods
D) Inheritance
Question
Which of the following is the correct syntax for defining a class dining which inherits from class furniture?

A) class furniture(dining)
B) class dining(furniture)
C) class furniture(dining):
D) class dining(furniture):
Question
What is the relationship called in which one object is a specialized version of another object?

A) Parent-child
B) Node
C) Is a
D) Class
Question
Which method can you use to determine whether an object is an instance of a class?

A) isinstance
B) isclass
C) isobject
D) isinheritance
Question
What concept involves a superclass and a subclass?

A) Polymorphism
B) Inheritance
C) Encapsulation
D) Methods
Question
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
Question
In an inheritance relationship, what is a specialized class called?

A) Superclass
B) Subclass
C) Object
D) Method
Question
Polymorphism works on any two class methods that have the same name.
Question
New attributes and methods may be added to a subclass, which makes it a(n) _______________ version of the superclass.
Question
In an inheritance relationship, a television is a(n) _______________ of the electronics class.
Question
The term _______________ refers to an object's ability to take different forms.
Question
_______________ allows subclasses to have methods with the same names as methods in their superclasses.
Question
A subclass may not override any method other than the __init__ method.
Question
In a UML diagram depicting inheritance, you only write the name of the subclass.
Question
_______________ is used to create an 'is a' relationship among classes.
Question
A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
Question
Superclasses are also called _______________ classes.
Question
The _______________ function determines whether an object is an instance of a specific class, or an instance of a subclass of that class.
Question
A subclass is also called a(n) _______________ class.
Question
In an inheritance relationship, the extended class is called the _______________.
Question
When a subclass method has the same name as a superclass method, it is often said that the subclass method _______________ the superclass method.
Question
One of the ingredients of polymorphic behavior is the ability to define a method in a subclass, and then define a method with the same name in a superclass.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 11: Inheritance
1
Of the two classes Cola and Soda, which would most likely be the subclass?

A) Cola
B) Soda
C) Both
D) Either
A
2
In the following line of code, what is the name of the base class?
Class Male(Human):

A) Male
B) Human
C) Either
D) Incorrect code
B
3
An 'is a' relationship exists between a grasshopper and a bumblebee.
False
4
What does a subclass inherit from a superclass?

A) Instances and attributes
B) Data and methods
C) Methods and instances
D) Attributes and methods
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
Base classes are also called _____.

A) superclasses
B) derived
C) subclasses
D) classes
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
Each subclass has a method named __init__ that overrides the superclass's __init__.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
New attributes and methods may be added to a subclass.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
Examine the following piece of code:
Class Potato (Vegetable):
In a UML diagram, what would the open arrowhead point to?

A) Potato
B) Vegetable
C) class
D) Potato(Vegetable)
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
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 35 flashcards in this deck.
Unlock Deck
k this deck
10
It is not possible to indicate inheritance in a UML diagram.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
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
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
In the following line of code, what is the name of the subclass?
Class Rose(Flower):

A) Rose
B) Flower
C) Either
D) Incorrect code
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
In a UML diagram, what does the open arrowhead point to?

A) Superclass
B) Subclass
C) Object
D) Method
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
_____ allows a new class to inherit the members of the class it extends.

A) Encapsulation
B) Domain
C) Methods
D) Inheritance
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following is the correct syntax for defining a class dining which inherits from class furniture?

A) class furniture(dining)
B) class dining(furniture)
C) class furniture(dining):
D) class dining(furniture):
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
What is the relationship called in which one object is a specialized version of another object?

A) Parent-child
B) Node
C) Is a
D) Class
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
Which method can you use to determine whether an object is an instance of a class?

A) isinstance
B) isclass
C) isobject
D) isinheritance
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
What concept involves a superclass and a subclass?

A) Polymorphism
B) Inheritance
C) Encapsulation
D) Methods
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
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
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
In an inheritance relationship, what is a specialized class called?

A) Superclass
B) Subclass
C) Object
D) Method
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
Polymorphism works on any two class methods that have the same name.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
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 35 flashcards in this deck.
Unlock Deck
k this deck
23
In an inheritance relationship, a television is a(n) _______________ of the electronics class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
The term _______________ refers to an object's ability to take different forms.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
_______________ allows subclasses to have methods with the same names as methods in their superclasses.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
A subclass may not override any method other than the __init__ method.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
In a UML diagram depicting inheritance, you only write the name of the subclass.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
_______________ is used to create an 'is a' relationship among classes.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
A superclass inherits attributes and methods from its subclasses without any of them having to be rewritten.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
Superclasses are also called _______________ classes.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
The _______________ function determines whether 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 35 flashcards in this deck.
Unlock Deck
k this deck
32
A subclass is also called a(n) _______________ class.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
In an inheritance relationship, the extended class is called the _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
When a subclass method has the same name as a superclass method, it is often said that the subclass method _______________ the superclass method.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
One of the ingredients of polymorphic behavior is the ability to define a method in a subclass, and then define a method with the same name in a superclass.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 35 flashcards in this deck.