Deck 15: Inheritance, Polymorphism, and Virtual Functions
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
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/43
Play
Full screen (f)
Deck 15: Inheritance, Polymorphism, and Virtual Functions
1
The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.
True
2
Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.
True
3
The __________ members of a base class are never accessible to a derived class.
A) private
B) public
C) protected
D) All of these
E) None of these
A) private
B) public
C) protected
D) All of these
E) None of these
A
4
C++11 provides a way for a derived class to inherit some of the base class's constructors.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
5
When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, it is considered
A) local binding
B) safe binding
C) static binding
D) dynamic binding
E) None of these
A) local binding
B) safe binding
C) static binding
D) dynamic binding
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
6
In C++11, using constructor inheritance, it is possible for any of the base class's constructors to be inherited.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
7
A derived class may not have any classes derived from it.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
8
The __________ constructor is called before the __________ constructor.
A) base, derived
B) derived, base
C) public, private
D) private, public
E) None of these
A) base, derived
B) derived, base
C) public, private
D) private, public
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
9
A member function of a derived class may not have the same name as a member function of a base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
10
The compiler performs __________ on virtual functions.
A) local binding
B) additional error checking
C) static binding
D) dynamic binding
E) None of these
A) local binding
B) additional error checking
C) static binding
D) dynamic binding
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
11
A derived class may become a base class if another class is derived from it.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
12
A __________ of a base class expects to be overridden in a derived class.
A) constructor function
B) destructor function
C) static function
D) virtual function
E) None of these
A) constructor function
B) destructor function
C) static function
D) virtual function
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
13
In C++11, if a derived class attempts to override a final member function, the compiler generates an error.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
14
The term __________ means the ability to take many forms.
A) inheritance
B) polymorphism
C) member function
D) encapsulation
E) None of these
A) inheritance
B) polymorphism
C) member function
D) encapsulation
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
15
More than one class may be derived from a base class.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
16
When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
17
In an inheritance situation, you may not pass arguments to a base class constructor.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
18
When you derive a class from an existing class, you __________ add new data and functions.
A) never
B) must
C) may
D) None of these
A) never
B) must
C) may
D) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
19
In OOP programming, __________ allows you to create new classes based on existing classes.
A) polymorphism
B) inheritance
C) function overloading
D) the copy constructor
E) None of these
A) polymorphism
B) inheritance
C) function overloading
D) the copy constructor
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
20
Pointers to a base class may be assigned the address of a derived class object.
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
21
Multiple inheritance opens the opportunity for a derived class to have ___________ members.
A) dynamic
B) private
C) public
D) ambiguous
E) None of these
A) dynamic
B) private
C) public
D) ambiguous
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
22
When member functions behave differently depending on which object performed the call, this is an example of
A) chaos theory
B) virtual insubordination
C) polymorphism
D) encapsulation
E) None of these
A) chaos theory
B) virtual insubordination
C) polymorphism
D) encapsulation
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
23
A virtual function is a function that expects to be __________ in a derived class.
A) ignored
B) called frequently
C) overridden
D) private
E) None of these
A) ignored
B) called frequently
C) overridden
D) private
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
24
Polymorphism is when __________ in a class hierarchy perform differently, depending on which object performs the call.
A) base class constructors
B) derived class constructors
C) member functions
D) derived class destructors
E) None of these
A) base class constructors
B) derived class constructors
C) member functions
D) derived class destructors
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
25
When a derived class has two or more base classes, the situation is called
A) multiple inheritance
B) multiplicity
C) polymorphism
D) encapsulation
E) None of these
A) multiple inheritance
B) multiplicity
C) polymorphism
D) encapsulation
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
26
What is being protected in the following statement?
Class Car :
Protected Vehicle
A) derived class functions
B) base class members
C) derived class data
D) future inherited classes
E) None of these
Class Car :
Protected Vehicle
A) derived class functions
B) base class members
C) derived class data
D) future inherited classes
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
27
A virtual function is declared by placing the __________ key word in front of the return type in the base class's function declaration.
A) virtual
B) private
C) public
D) protected
E) None of these
A) virtual
B) private
C) public
D) protected
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
28
Which of the following is commonly used to extend a class or to give it additional capabilities?
A) inheritance
B) privacy
C) the constructor
D) the destructor
E) None of these
A) inheritance
B) privacy
C) the constructor
D) the destructor
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
29
Functions that are dynamically bound by the compiler are __________ functions.
A) constructor
B) destructor
C) static
D) virtual
E) None of these
A) constructor
B) destructor
C) static
D) virtual
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
30
The __________ destructor is called before the __________ destructor.
A) base, derived
B) derived, base
C) public, private
D) private, public
E) None of these
A) base, derived
B) derived, base
C) public, private
D) private, public
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
31
The following statement allows the __________ members of the Car class to access __________ members of the Vehicle class. class Car :
Public Vehicle
A) private, private
B) public, private
C) protected, private
D) public, protected
E) None of these
Public Vehicle
A) private, private
B) public, private
C) protected, private
D) public, protected
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
32
Arguments are passed to the base class destructor by the __________ class __________ function.
A) derived, constructor
B) derived, destructor
C) base, constructor
D) base, destructor
E) None of these
A) derived, constructor
B) derived, destructor
C) base, constructor
D) base, destructor
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
33
C++11 introduced the __________ key word to help prevent subtle errors when overriding virtual functions.
A) const
B) final
C) override
D) virtual
E) None of these
A) const
B) final
C) override
D) virtual
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
34
Which is the base class in the following statement?
Class Car :
Public Vehicle
A) Car
B) Vehicle
C) public
D) class
E) None of these
Class Car :
Public Vehicle
A) Car
B) Vehicle
C) public
D) class
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
35
Which is the derived class in the following statement?
Class Car :
Protected Vehicle
A) Car
B) Vehicle
C) protected
D) There is no way to tell.
E) None of these
Class Car :
Protected Vehicle
A) Car
B) Vehicle
C) protected
D) There is no way to tell.
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
36
When more than one class is derived from a base class, the situation is called
A) polymorphism
B) multiplicity
C) population
D) encapsulation
E) None of these
A) polymorphism
B) multiplicity
C) population
D) encapsulation
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
37
Select all that apply. The base class's __________ affects the way its members are inherited by the derived class.
A) name
B) return data type
C) access specification
D) construction
E) None of these
A) name
B) return data type
C) access specification
D) construction
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
38
Multiple inheritance is when a __________ class has __________ base classes.
A) base, no
B) derived, two or more
C) derived, no
D) compound, more than two
E) None of these
A) base, no
B) derived, two or more
C) derived, no
D) compound, more than two
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
39
Arguments are passed to the base class by the __________ class __________ function.
A) derived, constructor
B) derived, destructor
C) base, constructor
D) base, destructor
E) None of these
A) derived, constructor
B) derived, destructor
C) base, constructor
D) base, destructor
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
40
Protected members of a base class are like __________, but they may be accessed by derived classes.
A) constructor functions
B) static members
C) private members
D) public members
E) None of these
A) constructor functions
B) static members
C) private members
D) public members
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
41
Select all that apply. Which of the following constructors cannot be inherited through constructor inheritance?
A) the default constructor
B) the virtual constructor
C) the move constructor
D) the copy constructor
E) the grand constructor
A) the default constructor
B) the virtual constructor
C) the move constructor
D) the copy constructor
E) the grand constructor
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
42
Select all that apply. In an inheritance situation, the new class that you create from an existing class is known as the
A) derived class
B) inheritor
C) child class
D) parental class
E) None of these
A) derived class
B) inheritor
C) child class
D) parental class
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck
43
Select all that apply. The base class access specification determines how __________ members in the base class may be accessed by derived classes.
A) private
B) public
C) constructed
D) protected
E) None of these
A) private
B) public
C) constructed
D) protected
E) None of these
Unlock Deck
Unlock for access to all 43 flashcards in this deck.
Unlock Deck
k this deck