Deck 12: 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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
Play
Full screen (f)
Deck 12: Inheritance
1
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)
In a UML diagram, what would the open arrowhead point to?
A) Potato
B) Vegetable
C) class
D) Potato(Vegetable)
B
2
Base classes are also called _____.
A) superclasses
B) derived
C) subclasses
D) classes
A) superclasses
B) derived
C) subclasses
D) classes
A
3
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):
A) class furniture(dining)
B) class dining(furniture)
C) class furniture(dining):
D) class dining(furniture):
D
4
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
5
Which method can you use to determine whether an object is an instance of a class?
A) isinstance
B) isclass
C) isobject
D) isinheritance
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
6
What concept involves a superclass and a subclass?
A) Polymorphism
B) Inheritance
C) Encapsulation
D) Methods
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
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
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
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
Of the two classes Cola and Soda, which would most likely be the subclass?
A) Cola
B) Soda
C) Both
D) Either
A) Cola
B) Soda
C) Both
D) Either
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
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
A) Male
B) Human
C) Either
D) Incorrect code
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
_____ allows a new class to inherit the members of the class it extends.
A) Encapsulation
B) Domain
C) Methods
D) Inheritance
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
12
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
13
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
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
14
In an inheritance relationship, what is a specialized class called?
A) Superclass
B) Subclass
C) Object
D) Method
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
15
What does a subclass inherit from a superclass?
A) Instances and attributes
B) Data and methods
C) Methods and instances
D) Attributes and methods
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
16
An 'is a' relationship exists between a grasshopper and a bumblebee.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
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 35 flashcards in this deck.
Unlock Deck
k this deck
18
In a UML diagram, what does the open arrowhead point to?
A) Superclass
B) Subclass
C) Object
D) Method
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
19
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
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
20
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
21
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
22
_______________ 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
23
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
24
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
25
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
26
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
27
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
28
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
29
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
30
_______________ 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
31
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
32
Superclasses are also called _______________ classes.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
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
34
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
35
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