Deck 14: Inheritance
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/30
العب
ملء الشاشة (f)
Deck 14: Inheritance
1
If class D is derived from class B,then we say that class D inherits from class B.
True
2
An object of a derived class type has exactly one type,the type with which it was declared.
False
3
If B is a base class of D,then D's members cannot access the private data members of B without regard to the kind of inheritance.
True
4
If class D is derived from class B then class D has only some of the members from B,and the additional members defined in D.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
5
If B is a public base class of D,then D's members cannot invoke public members functions of B.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
6
A programmer must have the source code for libraries to extend them,even using inheritance.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
7
You never put a declaration of an inherited member in the derived class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
8
If a base class constructor is not called explicitly in the definition of a derived class constructor,an error results.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
9
We can assign a base class object to a derived class variable.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
10
If B is a base class of D,then D's members cannot invoke private member functions of B without regard to the kind of inheritance.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
11
A base/member initialization list is preceded by
A)two colons
B)a dot (or period)
C)a single colon
D)a semicolon
A)two colons
B)a dot (or period)
C)a single colon
D)a semicolon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
12
Constructors are inherited.After all something has to initialize the inherited variables.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
13
If class D is derived from class B,we speak of D as the derived class and B as the base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
14
An inheritance chain of any desired length is possible.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
15
A programmer can use inheritance with an existing library for which only the header file and binary are available,to derive a class more suitable to her purpose.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
16
Deriving a class from a base class requires serious changes to the base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
17
The class D inherits from base class B using public inheritance.The class B has public member function f(),but the derived class has no function member with this signature.The f()is not available to an object of class D.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
18
In C++,inheritance has much to do with the gene pool.Explain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
19
When class D is derived from class B,the derived class is usually smaller.Explain.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
20
If class D is derived from class B,we speak of D as the child class and B as the parent class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following is correct syntax to declare C++ class B to be a public base class for derived class D
A)public base class B: class D {/*…*/};
B)class D : public class B {/* … */};
C)class D : public B {/* … */};
D)class B: public D { };
E)None of the above
A)public base class B: class D {/*…*/};
B)class D : public class B {/* … */};
C)class D : public B {/* … */};
D)class B: public D { };
E)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
22
Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we destroy an object of class Child,three destructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?
A)Child,Parent,GrandParent
B)Parent,GrandParent,Child
C)GrandParent,Child,Parent
D)GrandParent,Parent,Child
E)GrandParent,Child,Parent
A)Child,Parent,GrandParent
B)Parent,GrandParent,Child
C)GrandParent,Child,Parent
D)GrandParent,Parent,Child
E)GrandParent,Child,Parent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
23
Given the class below,tell to what value the default constructor initializes the data member.Name this initialization technique and give another way to write the constructor.
class A
{
public:
A();
private:
int a;
};
A::A(): a(17)
{
//deliberately empty
}
class A
{
public:
A();
private:
int a;
};
A::A(): a(17)
{
//deliberately empty
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
24
Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.This question concerns order of calls to constructors and destructors for these three classes.Declare an object of class Child.We know that Child,Parent and GrandParent constructors are called.In what order are these constructors are called? When the time comes to destroy the class Child object,we know that Child,Parent and GrandParent destructors are called.In what order are these destructor called?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
25
In the code for HourlyEmployee that is derived from Employee,the constructor code appears
HourlyEmployee::
HourlyEmployee(string theName,
string theNumber,
double theWageRate,
double theHours
)
: Employee(theName,theNumber),
wageRate(theWageRate),
hours(theHours)
{
// deliberately empty
}
Describe the purpose of the items after the colon (:)in this code.
HourlyEmployee::
HourlyEmployee(string theName,
string theNumber,
double theWageRate,
double theHours
)
: Employee(theName,theNumber),
wageRate(theWageRate),
hours(theHours)
{
// deliberately empty
}
Describe the purpose of the items after the colon (:)in this code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
26
What are the benefits of inheritance and Object Oriented Programming?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
27
When a derived class inherits from a base class,how is the base class constructor called?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
28
Suppose class Child is derived from class Parent that was in turn derived from class GrandParent.When we declare an object of class Child,three constructors are called: i)Child,ii)Parent,iii )GrandParent..What is the order?
A)Child,Parent,GrandParent
B)Parent,GrandParent,Child
C)GrandParent,Child,Parent
D)GrandParent,Parent,Child
E)GrandParent,Child,Parent
A)Child,Parent,GrandParent
B)Parent,GrandParent,Child
C)GrandParent,Child,Parent
D)GrandParent,Parent,Child
E)GrandParent,Child,Parent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
29
If a class B is a pubic base class for a derived class D,then an object of class D bears what relationship to class B?
A)A has-a relationship.
B)A fraternal relationship
C)An is-a relationship.
D)There is no relationship here.
A)A has-a relationship.
B)A fraternal relationship
C)An is-a relationship.
D)There is no relationship here.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck
30
Neither the assignment operator overloading nor the copy constructor is inherited.If you do not create one,does this mean that the derived class will have no assignment operator or copy constructor?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 30 في هذه المجموعة.
فتح الحزمة
k this deck