Deck 15: Polymorphism and Virtual Functions

Full screen (f)
exit full mode
Question
Static binding occurs when the compiler binds a function call at compile time.
Use Space or
up arrow
down arrow
to flip the card.
Question
In C++, polymorphism is very difficult to achieve unless you also use inheritance.
Question
Declaring a member function of a class to be a _ will cause the C++ compiler to use dynamic binding.

A)static function
B)destructor function
C)virtual function
D)constructor function
E)None of the above
Question
In C++, polymorphism is based on the ability to make member functions of a class

A)protected.
B)virtual.
C)static.
D)encapsulated.
E)None of the above
Question
A pure virtual function

A)must be accompanied by a virtual constructor of the same class.
B)must be overridden in a derived class for the function to be useful.
C)executes more efficiently than a non- pure virtual function.
D)All of the above
E)None of the above
Question
When the compiler binds a call to a member function using only information available at compile time, the compiler is said to use binding.

A)static
B)local
C)dynamic
D)safe
E)None of the above
Question
The term means the ability to take many forms.

A)polymorphism
B)inheritance
C)member function
D)encapsulation
E)None of the above
Question
To indicate that a member function of a class is pure virtual,

A)you must include the header file.
B)you use the keywords pure virtual.
C)you must put = 0 where the body of the function would go.
D)All of the above
E)None of the above
Question
A virtual function is declared by placing the keyword in front of the return type in the base class's function declaration.

A)protected
B)virtual
C)private
D)public
E)None of the above
Question
Polymorphism is when in a class hierarchy perform differently, depending upon the class of the object making the call.

A)derived class constructors
B)derived class destructors
C)member functions
D)base class constructors
E)None of the above
Question
When more than one class is derived from a base class, the situation is called

A)encapsulation.
B)multiplicity.
C)population.
D)polymorphism.
E)None of the above
Question
functions are dynamically bound by the compiler.

A)Constructor
B)Static
C)Destructor
D)Virtual
E)None of the above
Question
Pointers to a base class may be assigned the address of a derived class object.
Question
When a virtual member function of a class in a class hierarchy is invoked through a pointer to an object in the class hierarchy, the compiler will select the member function to be invoked

A)from the class of the object that is pointed to.
B)from the class of the type of the pointer.
C)from the base class of the inheritance hierarchy.
D)from the derived class of the base pointer object.
E)None of the above
Question
An abstract class is somewhat restricted in how it can be used because

A)All of its members must be public.
B)it cannot use dynamic binding for its member functions.
C)the compiler does not allow objects of the class to be created.
D)it cannot use static binding for its member functions.
E)None of the above
Question
A class with at least one pure virtual function is called

A)an abstract class.
B)a pure virtual class.
C)a virtual base class.
D)All of the above
E)None of the above
Question
An abstract class is

A)one that supports polymorphism.
B)one that has all of its member functions declared private.
C)one that has all of its member variables declared private.
D)one that has at least one pure virtual function.
E)None of the above
Question
Polymorphism in C++ will not work unless .

A)the header file is included
B)the members of the class are public
C)pointers or references are being used
D)All of the above
E)None of the above
Question
A pure virtual function

A)is a virtual function that has no implementation.
B)is a virtual function that performs a single task in program.
C)is a virtual function that has been completely debugged.
D)is one that is only called from within a virtual constructor.
E)None of the above
Question
to a base class may be assigned the address of a derived class object.

A)Access specifiers
B)Static members
C)Pointers
D)Private members
E)None of the above
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/20
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 15: Polymorphism and Virtual Functions
1
Static binding occurs when the compiler binds a function call at compile time.
True
2
In C++, polymorphism is very difficult to achieve unless you also use inheritance.
True
3
Declaring a member function of a class to be a _ will cause the C++ compiler to use dynamic binding.

A)static function
B)destructor function
C)virtual function
D)constructor function
E)None of the above
C
4
In C++, polymorphism is based on the ability to make member functions of a class

A)protected.
B)virtual.
C)static.
D)encapsulated.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
5
A pure virtual function

A)must be accompanied by a virtual constructor of the same class.
B)must be overridden in a derived class for the function to be useful.
C)executes more efficiently than a non- pure virtual function.
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
6
When the compiler binds a call to a member function using only information available at compile time, the compiler is said to use binding.

A)static
B)local
C)dynamic
D)safe
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
7
The term means the ability to take many forms.

A)polymorphism
B)inheritance
C)member function
D)encapsulation
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
8
To indicate that a member function of a class is pure virtual,

A)you must include the header file.
B)you use the keywords pure virtual.
C)you must put = 0 where the body of the function would go.
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
9
A virtual function is declared by placing the keyword in front of the return type in the base class's function declaration.

A)protected
B)virtual
C)private
D)public
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
10
Polymorphism is when in a class hierarchy perform differently, depending upon the class of the object making the call.

A)derived class constructors
B)derived class destructors
C)member functions
D)base class constructors
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
11
When more than one class is derived from a base class, the situation is called

A)encapsulation.
B)multiplicity.
C)population.
D)polymorphism.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
12
functions are dynamically bound by the compiler.

A)Constructor
B)Static
C)Destructor
D)Virtual
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
13
Pointers to a base class may be assigned the address of a derived class object.
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
14
When a virtual member function of a class in a class hierarchy is invoked through a pointer to an object in the class hierarchy, the compiler will select the member function to be invoked

A)from the class of the object that is pointed to.
B)from the class of the type of the pointer.
C)from the base class of the inheritance hierarchy.
D)from the derived class of the base pointer object.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
15
An abstract class is somewhat restricted in how it can be used because

A)All of its members must be public.
B)it cannot use dynamic binding for its member functions.
C)the compiler does not allow objects of the class to be created.
D)it cannot use static binding for its member functions.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
16
A class with at least one pure virtual function is called

A)an abstract class.
B)a pure virtual class.
C)a virtual base class.
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
17
An abstract class is

A)one that supports polymorphism.
B)one that has all of its member functions declared private.
C)one that has all of its member variables declared private.
D)one that has at least one pure virtual function.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
18
Polymorphism in C++ will not work unless .

A)the header file is included
B)the members of the class are public
C)pointers or references are being used
D)All of the above
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
19
A pure virtual function

A)is a virtual function that has no implementation.
B)is a virtual function that performs a single task in program.
C)is a virtual function that has been completely debugged.
D)is one that is only called from within a virtual constructor.
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
20
to a base class may be assigned the address of a derived class object.

A)Access specifiers
B)Static members
C)Pointers
D)Private members
E)None of the above
Unlock Deck
Unlock for access to all 20 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 20 flashcards in this deck.