Deck 15: Inheritance

ملء الشاشة (f)
exit full mode
سؤال
An object of a derived class can be stored in a base class variable
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Member functions defined as private in the base class are/are not)inherited in the derived class
سؤال
A derived class automatically gets all the member variables from the base class.
سؤال
All member functions in a base class should be listed as virtual functions.
سؤال
If the member variables in a base class are marked as private,can a derived class directly access those variables?
سؤال
The derived class may define variables and member functions other than those that are in the base class.
سؤال
If you use the keyword virtual in a function declaration,you must also use it in the function definition.
سؤال
The base class has everything that is in the derived class and more
سؤال
A constructor of the base class is ____ inherited in the derived class is/is not)
سؤال
When the derived class gets all the member variables from the base class,we say that they are _________ from the base class.
سؤال
When we derive one class from another class,this is known as ____________
سؤال
If the member variables of the base class are marked as protected,who can access those variables?
سؤال
The ability to associate multiple meanings to one function name using dynamic binding is called _________.
سؤال
Which is more general,the base class or the derive class.
سؤال
Destructors are not inherited into the derived class.
سؤال
The assignment operator is inherited from the base class.
سؤال
If two functions in the same scope)have the same name,but a different function signature,this means that the functions are __________.
سؤال
The copy constructor from the base class is not inherited into the derived class.
سؤال
The ifstream class is derived from the __________ class.
سؤال
The constructor for a class is inherited.
سؤال
Which of the following are true?

A)constructors of the base class are inherited in the derived class.
B)you may not call the base constructor from the derived class
C)You must define constructors in both the base and derived classes
D)all of the above
E)none of the above
سؤال
C++ implements polymorphism by waiting until run-time to determine which version of a function to use.This is also known as ______________.
سؤال
If you define a function in the derived class that has the same function signature as a function in the base class,this is known as

A)overloading
B)redefinition
C)overwriting
D)a syntax error
سؤال
Using inheritance allows us to

A)eliminate duplicate code
B)make our classes more modular
C)use polymorphism
D)all of the above
E)none of the above
سؤال
If you have the following class definitions,which of the following is the proper way to construct an object of the derived class?
Class Pet
{
Public:
Pet);
Void printPet);
String getName);
Void setNamestring newName);
Private:
String name;
};
Class Dog:public Pet
{
Public:
Dog);
Void printPet);
Void setTypestring newType);
String getType);
Private:
String type;
};

A)Dog::Dog):Pet),type"MUTT") {
}
B)Dog::Dog) {
Name="Rover";
}
C)Pet::Dog):Pet),type"MUTT") {
}
D)Dog::Pet):Pet),type"MUTT") {
}
سؤال
Which is the correct way to tell the compiler that the class being declared ChildClass)is derived from the base class BaseClass)?

A)class ChildClass::public BaseClass
B)class ChildClass:public BaseClass
C)class ChildClass childOf public BaseClass
D)class ChildClass derived BaseClass
سؤال
If the member variables in a base class are private,then

A)they can be directly accessed or changed in the derived class
B)the derived class must use any accesssor or modifier functions from the base class
C)making them private causes a syntax error.
D)you must declare them in the derived class also.
سؤال
In the derived class definition,you list from the base class

A)all the member functions every time
B)only those member functions that need to be redefined
C)only those member functions that were in the public section
D)only those member functions you want to overload.
سؤال
A base class may have at most _______ child class derived from it.

A)1
B)2
C)12
D)any number
سؤال
Another name for the base class is

A)parent class
B)super class
C)ancestor class
D)all of the above
E)none of the above
سؤال
When deriving a class,you should

A)list only base class functions that will be redefined
B)list all the member functions of the base class
C)make every function a virtual function
D)overload all the base class member functions
سؤال
A derived class pointer can point to
سؤال
Which of the following are not true

A)an object of the derived class may be stored in a variable of the base class
B)an object of the base class may be stored in a variable of the derived class
C)an object of a derived class that is derived from another class that is derived from a third class can be stored in a variable of the third class.
D)all of the above
E)none of the above
سؤال
If a base class has a public member function,and the derived class has a member function with the same name,but with a different parameter list,this function is said to be

A)overloaded
B)redefined
C)overwritten
D)a syntax error
سؤال
If a base class has declared a function to be a virtual function,then does the derived class need to include the word virtual also?
سؤال
If a base class has public member functions that are not listed by a derived class,then these functions

A)are not available to the derived class
B)are inherited unchanged in the derived class
C)are private to the derived class
D)do not exist in the derived class
سؤال
A base class pointer variable can point to
سؤال
What is another name for a child class?

A)derived class
B)sub class
C)descendent class
D)all of the above
E)none of the above
سؤال
Using virtual functions is also known as _______ the functions
سؤال
Give a base class with at least one public member function,how many classes can redefine that member function?

A)1
B)0
C)all of them
D)none of the above
سؤال
Which of the following should be virtual if a base class uses dynamic memory allocation?

A)the constructor
B)the copy constructor
C)the print function
D)the destructor
سؤال
In order to tell the compiler to wait to decide which version of a function to use,you must precede the function declaration in the base class with the keyword

A)operator
B)friend
C)virtual
D)void
سؤال
Which of the following would correctly call the base class BaseClass)assignment operator from the derived class DerivedClass)assignment operator?
DerivedClass& DerivedClass::operator =const DerivedClass& rightSide)
{
//what goes here?
}

A)BaseClass::operator=rightSide);
B)leftSide=rightSide;
C)rightSide=BaseClass.rightSide;
D)DerivedClass::rightSide=BaseClass::rightSide;
سؤال
Polymorphism refers to

A)the ability to assign multiple meanings to one function name.
B)overriding base class functions.
C)overloading functions
D)none of the above
سؤال
If you have a copy constructor in the base class,but do not have a copy constructor for the derived class,then

A)you will have a syntax error
B)a copy constructor for the derived class is automatically created for you
C)you can not use pointer variables
D)the default constructor is used
سؤال
Given a class A that derives from a class B that derives from a class C,when an object of class A goes out of scope,in which order are the destructors called?

A)C,B,then A
B)A,B,then C
C)unable to determine
D)depends on how the code is written for the destructors
سؤال
If a derived class Class2)has redefined a function from the base class Class 1),how can that derived function call the base class function if the function declaration is as follows?
Void print );

A):public Class1::print );
B)Class1 :: print );
C)print );
D)all of the above.
سؤال
You should make a function a virtual function if

A)every class that is derived from this class use all the member functions from this class.
B)every class that is derived from this class needs to re-define this function.
C)that function is an operator
D)only in the derived classes
سؤال
Given the following classes and code,what is the output of the last statement shown?
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Void Pet::print)
{
Cout << "My name is " << name;
}
Void Dog::print)
{
Pet::print);
Cout << ",and my breed is a "<< breed << endl;
}
Pet pPtr;
Dog dPtr;
DPtr->name= "Rover";
DPtr->breed="Weiner";
PPtr= dPtr;
PPtr->print);

A)My name is Rover,and my breed is a Weiner
B)My name is Rover
C),and my breed is a Weiner
D)nothing
سؤال
Given the following classes and code,what is the output of the last statement shown?
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Void Pet::print)
{
Cout << "My name is " << name;
}
Void Dog::print)
{
Pet::print);
Cout << ",and my breed is a "<< breed << endl;
}
Pet* pPtr;
Dog* dPtr=new Dog;
DPtr->name= "Rover";
DPtr->breed="Weiner";
PPtr= dPtr;
PPtr->print);

A)My name is Rover,and my breed is a Weiner
B)My name is Rover
C),and my breed is a Weiner
D)nothing
سؤال
If a base class has a non-virtual member function named print,and a pointer variable of that class is pointing to a derived object,then the code ptr->print ); calls

A)the base class print function
B)the derived print function
C)both the derived and base print functions
D)it causes a run-time error
سؤال
If a base class has a virtual function named print,and a pointer variable of that class is pointing to a derived object,then the code ptr->print ); calls

A)the base class print function
B)the derived print function
C)both the derived and base print functions
D)it causes a run-time error
سؤال
Given the following simplified classes,
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Dog vDog;
Pet vPet;
VDog.name="rover";
VDog.breed = "Collie";
Which of the following statements are not legal?

A)vPet=vDog; cout << vDog.name;
B)vPet=vDog; cout << vDog.breed;
C)vPet=vDog; cout << vPet.name;
D)vPet=vDog; cout << vPet.breed;
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/53
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 15: Inheritance
1
An object of a derived class can be stored in a base class variable
True
2
Member functions defined as private in the base class are/are not)inherited in the derived class
are not
3
A derived class automatically gets all the member variables from the base class.
True
4
All member functions in a base class should be listed as virtual functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
5
If the member variables in a base class are marked as private,can a derived class directly access those variables?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
6
The derived class may define variables and member functions other than those that are in the base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
7
If you use the keyword virtual in a function declaration,you must also use it in the function definition.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
8
The base class has everything that is in the derived class and more
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
9
A constructor of the base class is ____ inherited in the derived class is/is not)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
10
When the derived class gets all the member variables from the base class,we say that they are _________ from the base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
11
When we derive one class from another class,this is known as ____________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
12
If the member variables of the base class are marked as protected,who can access those variables?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
13
The ability to associate multiple meanings to one function name using dynamic binding is called _________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which is more general,the base class or the derive class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
15
Destructors are not inherited into the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
16
The assignment operator is inherited from the base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
17
If two functions in the same scope)have the same name,but a different function signature,this means that the functions are __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
18
The copy constructor from the base class is not inherited into the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
19
The ifstream class is derived from the __________ class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
20
The constructor for a class is inherited.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following are true?

A)constructors of the base class are inherited in the derived class.
B)you may not call the base constructor from the derived class
C)You must define constructors in both the base and derived classes
D)all of the above
E)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
22
C++ implements polymorphism by waiting until run-time to determine which version of a function to use.This is also known as ______________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
23
If you define a function in the derived class that has the same function signature as a function in the base class,this is known as

A)overloading
B)redefinition
C)overwriting
D)a syntax error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
24
Using inheritance allows us to

A)eliminate duplicate code
B)make our classes more modular
C)use polymorphism
D)all of the above
E)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
25
If you have the following class definitions,which of the following is the proper way to construct an object of the derived class?
Class Pet
{
Public:
Pet);
Void printPet);
String getName);
Void setNamestring newName);
Private:
String name;
};
Class Dog:public Pet
{
Public:
Dog);
Void printPet);
Void setTypestring newType);
String getType);
Private:
String type;
};

A)Dog::Dog):Pet),type"MUTT") {
}
B)Dog::Dog) {
Name="Rover";
}
C)Pet::Dog):Pet),type"MUTT") {
}
D)Dog::Pet):Pet),type"MUTT") {
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
26
Which is the correct way to tell the compiler that the class being declared ChildClass)is derived from the base class BaseClass)?

A)class ChildClass::public BaseClass
B)class ChildClass:public BaseClass
C)class ChildClass childOf public BaseClass
D)class ChildClass derived BaseClass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
27
If the member variables in a base class are private,then

A)they can be directly accessed or changed in the derived class
B)the derived class must use any accesssor or modifier functions from the base class
C)making them private causes a syntax error.
D)you must declare them in the derived class also.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
28
In the derived class definition,you list from the base class

A)all the member functions every time
B)only those member functions that need to be redefined
C)only those member functions that were in the public section
D)only those member functions you want to overload.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
29
A base class may have at most _______ child class derived from it.

A)1
B)2
C)12
D)any number
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
30
Another name for the base class is

A)parent class
B)super class
C)ancestor class
D)all of the above
E)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
31
When deriving a class,you should

A)list only base class functions that will be redefined
B)list all the member functions of the base class
C)make every function a virtual function
D)overload all the base class member functions
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
32
A derived class pointer can point to
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
33
Which of the following are not true

A)an object of the derived class may be stored in a variable of the base class
B)an object of the base class may be stored in a variable of the derived class
C)an object of a derived class that is derived from another class that is derived from a third class can be stored in a variable of the third class.
D)all of the above
E)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
34
If a base class has a public member function,and the derived class has a member function with the same name,but with a different parameter list,this function is said to be

A)overloaded
B)redefined
C)overwritten
D)a syntax error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
35
If a base class has declared a function to be a virtual function,then does the derived class need to include the word virtual also?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
36
If a base class has public member functions that are not listed by a derived class,then these functions

A)are not available to the derived class
B)are inherited unchanged in the derived class
C)are private to the derived class
D)do not exist in the derived class
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
37
A base class pointer variable can point to
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
38
What is another name for a child class?

A)derived class
B)sub class
C)descendent class
D)all of the above
E)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
39
Using virtual functions is also known as _______ the functions
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
40
Give a base class with at least one public member function,how many classes can redefine that member function?

A)1
B)0
C)all of them
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
41
Which of the following should be virtual if a base class uses dynamic memory allocation?

A)the constructor
B)the copy constructor
C)the print function
D)the destructor
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
42
In order to tell the compiler to wait to decide which version of a function to use,you must precede the function declaration in the base class with the keyword

A)operator
B)friend
C)virtual
D)void
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
43
Which of the following would correctly call the base class BaseClass)assignment operator from the derived class DerivedClass)assignment operator?
DerivedClass& DerivedClass::operator =const DerivedClass& rightSide)
{
//what goes here?
}

A)BaseClass::operator=rightSide);
B)leftSide=rightSide;
C)rightSide=BaseClass.rightSide;
D)DerivedClass::rightSide=BaseClass::rightSide;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
44
Polymorphism refers to

A)the ability to assign multiple meanings to one function name.
B)overriding base class functions.
C)overloading functions
D)none of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
45
If you have a copy constructor in the base class,but do not have a copy constructor for the derived class,then

A)you will have a syntax error
B)a copy constructor for the derived class is automatically created for you
C)you can not use pointer variables
D)the default constructor is used
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
46
Given a class A that derives from a class B that derives from a class C,when an object of class A goes out of scope,in which order are the destructors called?

A)C,B,then A
B)A,B,then C
C)unable to determine
D)depends on how the code is written for the destructors
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
47
If a derived class Class2)has redefined a function from the base class Class 1),how can that derived function call the base class function if the function declaration is as follows?
Void print );

A):public Class1::print );
B)Class1 :: print );
C)print );
D)all of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
48
You should make a function a virtual function if

A)every class that is derived from this class use all the member functions from this class.
B)every class that is derived from this class needs to re-define this function.
C)that function is an operator
D)only in the derived classes
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
49
Given the following classes and code,what is the output of the last statement shown?
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Void Pet::print)
{
Cout << "My name is " << name;
}
Void Dog::print)
{
Pet::print);
Cout << ",and my breed is a "<< breed << endl;
}
Pet pPtr;
Dog dPtr;
DPtr->name= "Rover";
DPtr->breed="Weiner";
PPtr= dPtr;
PPtr->print);

A)My name is Rover,and my breed is a Weiner
B)My name is Rover
C),and my breed is a Weiner
D)nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
50
Given the following classes and code,what is the output of the last statement shown?
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Void Pet::print)
{
Cout << "My name is " << name;
}
Void Dog::print)
{
Pet::print);
Cout << ",and my breed is a "<< breed << endl;
}
Pet* pPtr;
Dog* dPtr=new Dog;
DPtr->name= "Rover";
DPtr->breed="Weiner";
PPtr= dPtr;
PPtr->print);

A)My name is Rover,and my breed is a Weiner
B)My name is Rover
C),and my breed is a Weiner
D)nothing
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
51
If a base class has a non-virtual member function named print,and a pointer variable of that class is pointing to a derived object,then the code ptr->print ); calls

A)the base class print function
B)the derived print function
C)both the derived and base print functions
D)it causes a run-time error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
52
If a base class has a virtual function named print,and a pointer variable of that class is pointing to a derived object,then the code ptr->print ); calls

A)the base class print function
B)the derived print function
C)both the derived and base print functions
D)it causes a run-time error
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
53
Given the following simplified classes,
Class Pet
{
Public:
Virtual void print);
String name;
Private:
};
Class Dog: public Pet
{
Public:
Void print);
String breed;
};
Dog vDog;
Pet vPet;
VDog.name="rover";
VDog.breed = "Collie";
Which of the following statements are not legal?

A)vPet=vDog; cout << vDog.name;
B)vPet=vDog; cout << vDog.breed;
C)vPet=vDog; cout << vPet.name;
D)vPet=vDog; cout << vPet.breed;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 53 في هذه المجموعة.