Deck 10: Understanding Inheritance

Full screen (f)
exit full mode
Question
A(n) ____ is a very specific instance of a class.

A) superclass
B) derived class
C) object
D) child class
Use Space or
up arrow
down arrow
to flip the card.
Question
When a class serves as a base class to other classes, all of its members are included when you create an object from a derived class. However, the members of the base class that are ____ are not directly accessible from within the child class functions.

A) public
B) protected
C) private
D) virtual
Question
____ data and functions can be accessed only by class functions, or by functions in child classes.

A) public
B) protected
C) private
D) virtual
Question
To create a class Customer that derives from the class Person , you should use the following syntax:
Class Customer ____ public Person // public may be replaced
// by another class access
// specifier
{
// other statements go here
};

A) :
B) extends
C) ::
D) ->
Question
When a class is a base class you are required to define data as protected rather than private .
Question
____ is based on the principle that knowledge of a general category can be applied to more specific objects.

A) Overloading
B) Inheritance
C) Overriding
D) Polymorphism
Question
The children of a virtual base class cannot be used as a base to another class.
Question
A ____ function cannot be inherited.

A) virtual
B) friend
C) public
D) protected
Question
____ data and functions can be accessed only within a class.

A) public
B) protected
C) private
D) virtual
Question
Any child class function with the same name as the parent, yet with an argument list that differs from the parent's, ____ the parent function.

A) specializes
B) generalizes
C) overloads
D) overrides
Question
The three access specifiers available for class members in C++ are: public , private and ____.

A) virtual
B) restricted
C) friend
D) protected
Question
Any child class function with the same name and argument list as the parent ____ the parent function.

A) specializes
B) generalizes
C) overloads
D) overrides
Question
No matter which access specifier you use when creating a child class, access to parent class members never becomes more lenient than originally coded.
Question
To be truly "object-oriented," a programming language must allow inheritance.
Question
The ____ access specifier allows members to be used by class member functions and by derived classes, but not by other parts of a program.

A) protected
B) virtual
C) private
D) friend
Question
C++ programmers usually use the ____ access specifier for inheritance.

A) public
B) protected
C) private
D) friend
Question
____ data and functions can be accessed anywhere the class is in scope.

A) public
B) protected
C) private
D) virtual
Question
A derived class is also called a subclass or descendant.
Question
Class friendship is not inherited.
Question
Inheritance is said to use the ____ relationship.

A) "has a"
B) "extends"
C) "is a"
D) "specializes"
Question
Why are functions sometime overridden in derived classes?
Question
Multiple inheritance is ____ required.

A) always
B) never
C) rarely
D) frequently
Question
When a derived class object is destroyed, the ____________________ class destructor is called first.
Question
When a child class function overrides a parent class function, you can say that you have ____________________ the function.
Question
The following code is an example of the correct use of the virtual keyword (assume Student is a subclass of Person ): ____.

A) virtual public Person
B) class Student : public Person (virtual)
C) virtual class Student : public Person
D) class Student : virtual public Person
Question
A(n) ____________________ class is also called the superclass, or ancestor.
Question
Many of the constructor complications that occur when inheriting from multiple classes are minimized if you always include ____.

A) a default constructor for every class
B) the virtual keyword when declaring the parent class
C) a friend function
D) an specialized destructor
Question
When you instantiate a class object that has been derived from another class, ____.

A) the constructor for the base class is called first, followed by the derived class constructor
B) the constructor for the derived class is called first, followed by the base class constructor
C) only the constructor for the derived class is called
D) only the constructor for the base class is called
Question
Overriding a base class member function with a derived member function demonstrates the concept of ____.

A) abstraction
B) polymorphism
C) inheritance
D) overloading
Question
____________________ in C++ means you can create classes that derive their attributes from existing classes.
Question
Provide an example of a situation in which you would want to use inheritance when creating classes.
Question
If a base class contains a function that the derived class should not have, you can create a ____________________ function with the same name in the derived class.
Question
With respect to inheritance, what do generalization and specialization mean?
Question
Consider the following code segments:
class Person
{
private:
int idNum;
string lastName;
string firstName;
public:
void setFields(int, string, string);
void outputData();
};
class Customer : public Person
{
private:
double balanceDue;
public:
void setBalDue(double);
void outputBalDue();
};
void Customer::outputBalDue()
{
cout
What error does the outputBalDue() function have?
Question
What are the advantages provided by inheritance?
Question
Why does inheritance save you time?
Question
Consider an object aWorker of class Worker , and a variable aPerson of class Person , where Worker is a subclass of Person . Which of the following is valid without writing a specialized function?

A) aPerson + aWorker
B) aPerson * aWorker
C) aWorker = aPerson
D) aPerson = aWorker
Question
If you do not use an access specifier when you create a derived class, access is ____________________ by default.
Question
What should be the first line of the class declaration for the class RV that is both a Vehicle and a Dwelling ?

A) class RV : public Vehicle && public Dwelling
B) class RV : public Vehicle and implements public Dwelling
C) class RV : public Vehicle, public Dwelling
D) class RV : public Vehicle Dwelling
Question
When you define a derived class, you can insert one of the three class access specifiers just prior to the ____________________ name.
Question
Match between columns
indicates that a base class should be used only once
reliable class
indicates that a base class should be used only once
virtual
indicates that a base class should be used only once
parent class
indicates that a base class should be used only once
single inheritance
indicates that a base class should be used only once
multiple inheritance
indicates that a base class should be used only once
inaccessible class member
indicates that a base class should be used only once
override (a function)
indicates that a base class should be used only once
derived class
indicates that a base class should be used only once
invoke a method
Question
What happens if a derived class uses the protected access specifier for inheritance?
Question
What are the items that are never inherited by a child class?
Question
Match between columns
a child class can derive from more than one base class
reliable class
a child class can derive from more than one base class
virtual
a child class can derive from more than one base class
parent class
a child class can derive from more than one base class
single inheritance
a child class can derive from more than one base class
multiple inheritance
a child class can derive from more than one base class
inaccessible class member
a child class can derive from more than one base class
override (a function)
a child class can derive from more than one base class
derived class
a child class can derive from more than one base class
invoke a method
Question
Can you create an array of parent class objects and store child class objects in it? What happens when you do this?
Question
Consider the following code fragments:
class PetStoreItem
{
protected:
int stockNum;
double price;
public:
PetStoreItem(int, double);
};
class PetStoreAnimal : public PetStoreItem
{
protected:
int petAge;
public:
PetStoreAnimal(int);
};
PetStoreAnimal::PetStoreAnimal(int age)
{
petAge = age;
}
Change the PetStoreAnimal constructor to avoid getting an error.
Question
Match between columns
when a child class derives from a single parent
reliable class
when a child class derives from a single parent
virtual
when a child class derives from a single parent
parent class
when a child class derives from a single parent
single inheritance
when a child class derives from a single parent
multiple inheritance
when a child class derives from a single parent
inaccessible class member
when a child class derives from a single parent
override (a function)
when a child class derives from a single parent
derived class
when a child class derives from a single parent
invoke a method
Question
Match between columns
to call a function
reliable class
to call a function
virtual
to call a function
parent class
to call a function
single inheritance
to call a function
multiple inheritance
to call a function
inaccessible class member
to call a function
override (a function)
to call a function
derived class
to call a function
invoke a method
Question
Match between columns
one that cannot be used from the current location
reliable class
one that cannot be used from the current location
virtual
one that cannot be used from the current location
parent class
one that cannot be used from the current location
single inheritance
one that cannot be used from the current location
multiple inheritance
one that cannot be used from the current location
inaccessible class member
one that cannot be used from the current location
override (a function)
one that cannot be used from the current location
derived class
one that cannot be used from the current location
invoke a method
Question
Match between columns
class that is already known to work correctly
reliable class
class that is already known to work correctly
virtual
class that is already known to work correctly
parent class
class that is already known to work correctly
single inheritance
class that is already known to work correctly
multiple inheritance
class that is already known to work correctly
inaccessible class member
class that is already known to work correctly
override (a function)
class that is already known to work correctly
derived class
class that is already known to work correctly
invoke a method
Question
Match between columns
to substitute one version of the function for another
reliable class
to substitute one version of the function for another
virtual
to substitute one version of the function for another
parent class
to substitute one version of the function for another
single inheritance
to substitute one version of the function for another
multiple inheritance
to substitute one version of the function for another
inaccessible class member
to substitute one version of the function for another
override (a function)
to substitute one version of the function for another
derived class
to substitute one version of the function for another
invoke a method
Question
Match between columns
class from which another is derived
reliable class
class from which another is derived
virtual
class from which another is derived
parent class
class from which another is derived
single inheritance
class from which another is derived
multiple inheritance
class from which another is derived
inaccessible class member
class from which another is derived
override (a function)
class from which another is derived
derived class
class from which another is derived
invoke a method
Question
Match between columns
child class
reliable class
child class
virtual
child class
parent class
child class
single inheritance
child class
multiple inheritance
child class
inaccessible class member
child class
override (a function)
child class
derived class
child class
invoke a method
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/53
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Understanding Inheritance
1
A(n) ____ is a very specific instance of a class.

A) superclass
B) derived class
C) object
D) child class
C
2
When a class serves as a base class to other classes, all of its members are included when you create an object from a derived class. However, the members of the base class that are ____ are not directly accessible from within the child class functions.

A) public
B) protected
C) private
D) virtual
C
3
____ data and functions can be accessed only by class functions, or by functions in child classes.

A) public
B) protected
C) private
D) virtual
B
4
To create a class Customer that derives from the class Person , you should use the following syntax:
Class Customer ____ public Person // public may be replaced
// by another class access
// specifier
{
// other statements go here
};

A) :
B) extends
C) ::
D) ->
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
5
When a class is a base class you are required to define data as protected rather than private .
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
6
____ is based on the principle that knowledge of a general category can be applied to more specific objects.

A) Overloading
B) Inheritance
C) Overriding
D) Polymorphism
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
7
The children of a virtual base class cannot be used as a base to another class.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
8
A ____ function cannot be inherited.

A) virtual
B) friend
C) public
D) protected
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
9
____ data and functions can be accessed only within a class.

A) public
B) protected
C) private
D) virtual
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
10
Any child class function with the same name as the parent, yet with an argument list that differs from the parent's, ____ the parent function.

A) specializes
B) generalizes
C) overloads
D) overrides
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
11
The three access specifiers available for class members in C++ are: public , private and ____.

A) virtual
B) restricted
C) friend
D) protected
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
12
Any child class function with the same name and argument list as the parent ____ the parent function.

A) specializes
B) generalizes
C) overloads
D) overrides
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
13
No matter which access specifier you use when creating a child class, access to parent class members never becomes more lenient than originally coded.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
14
To be truly "object-oriented," a programming language must allow inheritance.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
15
The ____ access specifier allows members to be used by class member functions and by derived classes, but not by other parts of a program.

A) protected
B) virtual
C) private
D) friend
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
16
C++ programmers usually use the ____ access specifier for inheritance.

A) public
B) protected
C) private
D) friend
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
17
____ data and functions can be accessed anywhere the class is in scope.

A) public
B) protected
C) private
D) virtual
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
18
A derived class is also called a subclass or descendant.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
19
Class friendship is not inherited.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
20
Inheritance is said to use the ____ relationship.

A) "has a"
B) "extends"
C) "is a"
D) "specializes"
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
21
Why are functions sometime overridden in derived classes?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
22
Multiple inheritance is ____ required.

A) always
B) never
C) rarely
D) frequently
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
23
When a derived class object is destroyed, the ____________________ class destructor is called first.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
24
When a child class function overrides a parent class function, you can say that you have ____________________ the function.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
25
The following code is an example of the correct use of the virtual keyword (assume Student is a subclass of Person ): ____.

A) virtual public Person
B) class Student : public Person (virtual)
C) virtual class Student : public Person
D) class Student : virtual public Person
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
26
A(n) ____________________ class is also called the superclass, or ancestor.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
27
Many of the constructor complications that occur when inheriting from multiple classes are minimized if you always include ____.

A) a default constructor for every class
B) the virtual keyword when declaring the parent class
C) a friend function
D) an specialized destructor
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
28
When you instantiate a class object that has been derived from another class, ____.

A) the constructor for the base class is called first, followed by the derived class constructor
B) the constructor for the derived class is called first, followed by the base class constructor
C) only the constructor for the derived class is called
D) only the constructor for the base class is called
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
29
Overriding a base class member function with a derived member function demonstrates the concept of ____.

A) abstraction
B) polymorphism
C) inheritance
D) overloading
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
30
____________________ in C++ means you can create classes that derive their attributes from existing classes.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
31
Provide an example of a situation in which you would want to use inheritance when creating classes.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
32
If a base class contains a function that the derived class should not have, you can create a ____________________ function with the same name in the derived class.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
33
With respect to inheritance, what do generalization and specialization mean?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
34
Consider the following code segments:
class Person
{
private:
int idNum;
string lastName;
string firstName;
public:
void setFields(int, string, string);
void outputData();
};
class Customer : public Person
{
private:
double balanceDue;
public:
void setBalDue(double);
void outputBalDue();
};
void Customer::outputBalDue()
{
cout
What error does the outputBalDue() function have?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
35
What are the advantages provided by inheritance?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
36
Why does inheritance save you time?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
37
Consider an object aWorker of class Worker , and a variable aPerson of class Person , where Worker is a subclass of Person . Which of the following is valid without writing a specialized function?

A) aPerson + aWorker
B) aPerson * aWorker
C) aWorker = aPerson
D) aPerson = aWorker
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
38
If you do not use an access specifier when you create a derived class, access is ____________________ by default.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
39
What should be the first line of the class declaration for the class RV that is both a Vehicle and a Dwelling ?

A) class RV : public Vehicle && public Dwelling
B) class RV : public Vehicle and implements public Dwelling
C) class RV : public Vehicle, public Dwelling
D) class RV : public Vehicle Dwelling
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
40
When you define a derived class, you can insert one of the three class access specifiers just prior to the ____________________ name.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
41
Match between columns
indicates that a base class should be used only once
reliable class
indicates that a base class should be used only once
virtual
indicates that a base class should be used only once
parent class
indicates that a base class should be used only once
single inheritance
indicates that a base class should be used only once
multiple inheritance
indicates that a base class should be used only once
inaccessible class member
indicates that a base class should be used only once
override (a function)
indicates that a base class should be used only once
derived class
indicates that a base class should be used only once
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
42
What happens if a derived class uses the protected access specifier for inheritance?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
43
What are the items that are never inherited by a child class?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
44
Match between columns
a child class can derive from more than one base class
reliable class
a child class can derive from more than one base class
virtual
a child class can derive from more than one base class
parent class
a child class can derive from more than one base class
single inheritance
a child class can derive from more than one base class
multiple inheritance
a child class can derive from more than one base class
inaccessible class member
a child class can derive from more than one base class
override (a function)
a child class can derive from more than one base class
derived class
a child class can derive from more than one base class
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
45
Can you create an array of parent class objects and store child class objects in it? What happens when you do this?
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
46
Consider the following code fragments:
class PetStoreItem
{
protected:
int stockNum;
double price;
public:
PetStoreItem(int, double);
};
class PetStoreAnimal : public PetStoreItem
{
protected:
int petAge;
public:
PetStoreAnimal(int);
};
PetStoreAnimal::PetStoreAnimal(int age)
{
petAge = age;
}
Change the PetStoreAnimal constructor to avoid getting an error.
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
47
Match between columns
when a child class derives from a single parent
reliable class
when a child class derives from a single parent
virtual
when a child class derives from a single parent
parent class
when a child class derives from a single parent
single inheritance
when a child class derives from a single parent
multiple inheritance
when a child class derives from a single parent
inaccessible class member
when a child class derives from a single parent
override (a function)
when a child class derives from a single parent
derived class
when a child class derives from a single parent
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
48
Match between columns
to call a function
reliable class
to call a function
virtual
to call a function
parent class
to call a function
single inheritance
to call a function
multiple inheritance
to call a function
inaccessible class member
to call a function
override (a function)
to call a function
derived class
to call a function
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
49
Match between columns
one that cannot be used from the current location
reliable class
one that cannot be used from the current location
virtual
one that cannot be used from the current location
parent class
one that cannot be used from the current location
single inheritance
one that cannot be used from the current location
multiple inheritance
one that cannot be used from the current location
inaccessible class member
one that cannot be used from the current location
override (a function)
one that cannot be used from the current location
derived class
one that cannot be used from the current location
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
50
Match between columns
class that is already known to work correctly
reliable class
class that is already known to work correctly
virtual
class that is already known to work correctly
parent class
class that is already known to work correctly
single inheritance
class that is already known to work correctly
multiple inheritance
class that is already known to work correctly
inaccessible class member
class that is already known to work correctly
override (a function)
class that is already known to work correctly
derived class
class that is already known to work correctly
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
51
Match between columns
to substitute one version of the function for another
reliable class
to substitute one version of the function for another
virtual
to substitute one version of the function for another
parent class
to substitute one version of the function for another
single inheritance
to substitute one version of the function for another
multiple inheritance
to substitute one version of the function for another
inaccessible class member
to substitute one version of the function for another
override (a function)
to substitute one version of the function for another
derived class
to substitute one version of the function for another
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
52
Match between columns
class from which another is derived
reliable class
class from which another is derived
virtual
class from which another is derived
parent class
class from which another is derived
single inheritance
class from which another is derived
multiple inheritance
class from which another is derived
inaccessible class member
class from which another is derived
override (a function)
class from which another is derived
derived class
class from which another is derived
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
53
Match between columns
child class
reliable class
child class
virtual
child class
parent class
child class
single inheritance
child class
multiple inheritance
child class
inaccessible class member
child class
override (a function)
child class
derived class
child class
invoke a method
Unlock Deck
Unlock for access to all 53 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 53 flashcards in this deck.