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
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/38
Play
Full screen (f)
Deck 15: Inheritance, Polymorphism, and Virtual Functions
1
When more than one class is derived from a base class, the situation is called:
A) polymorphism
B) population
C) multiplicity
D) encapsulation
E) None of these
A) polymorphism
B) population
C) multiplicity
D) encapsulation
E) None of these
E
2
The base class access specification determines how ___________ members in the base class may be accessed by derived classes.
A) private
B) public
C) protected
D) a, b, and c
E) None of these
A) private
B) public
C) protected
D) a, b, and c
E) None of these
D
3
When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, this is considered __________ binding.
A) local
B) safe
C) static
D) dynamic
E) None of these
A) local
B) safe
C) static
D) dynamic
E) None of these
C
4
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 38 flashcards in this deck.
Unlock Deck
k this deck
5
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 38 flashcards in this deck.
Unlock Deck
k this deck
6
_________ members of a base class are never accessible to a derived class.
A) Public
B) Private
C) Protected
D) a, b, and c
E) None of these
A) Public
B) Private
C) Protected
D) a, b, and c
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
7
The following statement class Car : private Vehicle
Allows the __________ members of the Car class to access ___________ members of the Vehicle class.
A) private, private
B) public, private
C) protected, private
D) public, protected
E) None of these
Allows the __________ members of the Car class to access ___________ members of the Vehicle class.
A) private, private
B) public, private
C) protected, private
D) public, protected
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
8
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 38 flashcards in this deck.
Unlock Deck
k this deck
9
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 38 flashcards in this deck.
Unlock Deck
k this deck
10
When you derive a class from an existing class, you _________ add new data and functions.
A) may never
B) may sometimes
C) may
D) None of these
A) may never
B) may sometimes
C) may
D) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
11
_________ allows us 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 38 flashcards in this deck.
Unlock Deck
k this deck
12
_____________ to a base class may be assigned the address of a derived class object.
A) Access specifiers
B) Static members
C) Private members
D) Pointers
E) None of these
A) Access specifiers
B) Static members
C) Private members
D) Pointers
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
13
In the statement class car : public vehicle, which is the base class?
A) car
B) vehicle
C) public
D) class
E) None of these
A) car
B) vehicle
C) public
D) class
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
14
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) a and b
E) None of these
A) name
B) return data type
C) access specification
D) a and b
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
15
In an inheritance situation, the new class that you create from an existing class is known as the ____________.
A) derived class
B) inheritee
C) child class
D) a and c
E) None of these
A) derived class
B) inheritee
C) child class
D) a and c
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
16
Arguments are passed to the base class destructor function 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 38 flashcards in this deck.
Unlock Deck
k this deck
17
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 38 flashcards in this deck.
Unlock Deck
k this deck
18
The compiler performs __________ on virtual functions.
A) static binding
B) dynamic binding
C) additional error checking
D) no special services
E) None of these
A) static binding
B) dynamic binding
C) additional error checking
D) no special services
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
19
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 38 flashcards in this deck.
Unlock Deck
k this deck
20
When a derived class has two or more base classes, the situation is known as __________.
A) multiple inheritance
B) polymorphism
C) encapsulation
D) access specification
E) None of these
A) multiple inheritance
B) polymorphism
C) encapsulation
D) access specification
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
21
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.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
22
A virtual function is a member 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 38 flashcards in this deck.
Unlock Deck
k this deck
23
More than one class may be derived from a base class.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
24
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 38 flashcards in this deck.
Unlock Deck
k this deck
25
Pointers to a base class may be assigned the address of a derived class object.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
26
In an inheritance situation, you may not pass arguments to a base class constructor.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
27
__________ functions are dynamically bound by the compiler.
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 38 flashcards in this deck.
Unlock Deck
k this deck
28
Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
29
In the following statement class car : protected vehicle
What is being protected?
A) derived class functions
B) base class members
C) derived class data
D) future inherited classes
E) None of these
What is being protected?
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 38 flashcards in this deck.
Unlock Deck
k this deck
30
In the following statement class Car : protected Vehicle
Which is the derived class?
A) Car
B) Vehicle
C) protected
D) cannot be determined
E) None of these
Which is the derived class?
A) Car
B) Vehicle
C) protected
D) cannot be determined
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
31
A virtual function is declared by placing the keyword _______ 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 38 flashcards in this deck.
Unlock Deck
k this deck
32
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 38 flashcards in this deck.
Unlock Deck
k this deck
33
A derived class may not have any classes derived from it.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
34
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 38 flashcards in this deck.
Unlock Deck
k this deck
35
____________ 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 38 flashcards in this deck.
Unlock Deck
k this deck
36
When member functions behave differently, depending upon 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 38 flashcards in this deck.
Unlock Deck
k this deck
37
A derived class may become a base class, if another class is derived from it.
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck
38
Polymorphism is when ____________ in a class hierarchy perform differently, depending upon which object performs the call.
A) base class constructors
B) derived class destructors
C) member functions
D) derived class constructors
E) None of these
A) base class constructors
B) derived class destructors
C) member functions
D) derived class constructors
E) None of these
Unlock Deck
Unlock for access to all 38 flashcards in this deck.
Unlock Deck
k this deck