Deck 12: Object-Oriented Programming: Inheritance

ملء الشاشة (f)
exit full mode
سؤال
When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?

A) protected, private
B) public, private
C) protected, protected
D) public, protected
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Base class constructors and assignment operators:

A) Are not inherited by derived classes.
B) Should not be called by derived class constructors and assignment operators.
C) Can be inherited by derived classes, but generally are not.
D) Can call derived-class constructors and assignment operators.
سؤال
Public CommissionEmployee
Which of the following is false?

A) The colon : ) in the header of the class definition indicates inheritance.
B) The keyword public indicates the type of inheritance.
C) All the public and protected members of class BasePlusCommissionEmployee are inherited as public and protected members, respectively, into class CommissionEmployee.
D) CommissionEmployee is the base class and BasePlusCommissionEmployee is the derived class.
سؤال
CommissionEmployee first, last, ssn, sales, rate )
The second line:

A) Invokes the CommissionEmployee constructor with arguments.
B) Causes a compiler error.
C) Is unnecessary because the CommissionEmployee constructor is called automatically.
D) Indicates inheritance.
سؤال
The is-a relationship represents.

A) Composition.
B) Inheritance.
C) Information Hiding.
D) A friend.
سؤال
Which of the following is not a kind of inheritance in C++?

A) public.
B) private.
C) static.
D) protected.
سؤال
Protected base class members cannot be accessed by:

A) Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class.
B) friends of the base class.
C) Functions that are not derived-class member functions.
D) friends of derived classes.
سؤال
From most restrictive to least restrictive, the access modifiers are:

A) protected, private, public
B) private, protected, public
C) private, public, protected
D) protected, public, private
سؤال
Suppose class A inherits from base class B. What is the order in which their constructors and destructors will be called when an object of class A is instantiated and then destroyed?

A) B constructor, A constructor, A destructor, B destructor.
B) B constructor, A constructor, B destructor, A destructor.
C) A constructor, B constructor, A destructor, B destructor.
D) A constructor, B constructor, B destructor, A destructor.
سؤال
Which of the following is not a good example of a hierarchy likely to be modeled by inheritance?

A) Airplanes.
B) Geometric shapes.
C) Animals.
D) Prime numbers.
سؤال
When should base class members be declared protected?

A) When all clients should be able to access these members.
B) When these members are used only by member functions of this base class.
C) When these members should be available only to derived classes and friends), but not to other clients.
D) The protected access specified should never be used.
سؤال
Which forms of inheritance are is-a relationships?

A) All forms of inheritance are is-a relationships.
B) Only public and private.
C) Only public and protected.
D) Only public.
سؤال
Which of the following is true about using inheritance in software engineering?

A) Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.
B) It is best to create a huge class library to make it easy for a client to find the most appropriate class for his or her needs.
C) A class produced through inheritance should be as large as possible to fully encompass all of the functionality it should offer.
D) The standard C++ libraries that are shipped with C++ compilers are usually enough to accomplish anything an application might need to do.
سؤال
Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?

A) Errors are prone to be spread around.
B) It is time consuming.
C) It forces the system to store many physical copies of the code, creating a code-maintenance nightmare.
D) All of the above are disadvantages of the "copy-and-paste" approach.
سؤال
When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.

A) Base class, base class.
B) Derived class, base class.
C) Base class, derived class.
D) Derived class, public.
سؤال
Which of the following is most likely a base class of the other three?

A) automobile.
B) convertible.
C) miniVan.
D) sedan.
سؤال
Select the false statement regarding inheritance.

A) A derived class can contain more attributes and behaviors than its base class.
B) A derived class can be the base class for other derived classes.
C) Some derived classes can have multiple base classes.
D) Base classes are usually more specific than derived classes.
سؤال
To declare class subClass a privately derived class of superClass one would write:

A) class subclass : private superClass
B) class subclass :: private superClass
C) class subclass < private superClass >
D) class subclass inherits private superClass
سؤال
Theoretically, clients do not need to see the _________ of classes from which they derive other classes.

A) Header files.
B) Source code.
C) Object code.
D) Interface.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/19
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 12: Object-Oriented Programming: Inheritance
1
When deriving a class from a protected base class, the public members of the base class become _________ and the protected members of the base class become __________?

A) protected, private
B) public, private
C) protected, protected
D) public, protected
C
2
Base class constructors and assignment operators:

A) Are not inherited by derived classes.
B) Should not be called by derived class constructors and assignment operators.
C) Can be inherited by derived classes, but generally are not.
D) Can call derived-class constructors and assignment operators.
A
3
Public CommissionEmployee
Which of the following is false?

A) The colon : ) in the header of the class definition indicates inheritance.
B) The keyword public indicates the type of inheritance.
C) All the public and protected members of class BasePlusCommissionEmployee are inherited as public and protected members, respectively, into class CommissionEmployee.
D) CommissionEmployee is the base class and BasePlusCommissionEmployee is the derived class.
C
4
CommissionEmployee first, last, ssn, sales, rate )
The second line:

A) Invokes the CommissionEmployee constructor with arguments.
B) Causes a compiler error.
C) Is unnecessary because the CommissionEmployee constructor is called automatically.
D) Indicates inheritance.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
5
The is-a relationship represents.

A) Composition.
B) Inheritance.
C) Information Hiding.
D) A friend.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following is not a kind of inheritance in C++?

A) public.
B) private.
C) static.
D) protected.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
7
Protected base class members cannot be accessed by:

A) Functions that are neither friends of the base class, derived-class member functions nor friends of a derived class.
B) friends of the base class.
C) Functions that are not derived-class member functions.
D) friends of derived classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
8
From most restrictive to least restrictive, the access modifiers are:

A) protected, private, public
B) private, protected, public
C) private, public, protected
D) protected, public, private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
9
Suppose class A inherits from base class B. What is the order in which their constructors and destructors will be called when an object of class A is instantiated and then destroyed?

A) B constructor, A constructor, A destructor, B destructor.
B) B constructor, A constructor, B destructor, A destructor.
C) A constructor, B constructor, A destructor, B destructor.
D) A constructor, B constructor, B destructor, A destructor.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following is not a good example of a hierarchy likely to be modeled by inheritance?

A) Airplanes.
B) Geometric shapes.
C) Animals.
D) Prime numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
11
When should base class members be declared protected?

A) When all clients should be able to access these members.
B) When these members are used only by member functions of this base class.
C) When these members should be available only to derived classes and friends), but not to other clients.
D) The protected access specified should never be used.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which forms of inheritance are is-a relationships?

A) All forms of inheritance are is-a relationships.
B) Only public and private.
C) Only public and protected.
D) Only public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following is true about using inheritance in software engineering?

A) Common attributes and behaviors should be factored out of closely related classes and placed into a base class from which the original classes can now inherit.
B) It is best to create a huge class library to make it easy for a client to find the most appropriate class for his or her needs.
C) A class produced through inheritance should be as large as possible to fully encompass all of the functionality it should offer.
D) The standard C++ libraries that are shipped with C++ compilers are usually enough to accomplish anything an application might need to do.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following is not one of the disadvantages of using the "copy-and-paste" approach to duplicating code from one class into another class?

A) Errors are prone to be spread around.
B) It is time consuming.
C) It forces the system to store many physical copies of the code, creating a code-maintenance nightmare.
D) All of the above are disadvantages of the "copy-and-paste" approach.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
15
When an object of a derived class is instantiated, the __________ constructor initializes the _________ members.

A) Base class, base class.
B) Derived class, base class.
C) Base class, derived class.
D) Derived class, public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
16
Which of the following is most likely a base class of the other three?

A) automobile.
B) convertible.
C) miniVan.
D) sedan.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
17
Select the false statement regarding inheritance.

A) A derived class can contain more attributes and behaviors than its base class.
B) A derived class can be the base class for other derived classes.
C) Some derived classes can have multiple base classes.
D) Base classes are usually more specific than derived classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
18
To declare class subClass a privately derived class of superClass one would write:

A) class subclass : private superClass
B) class subclass :: private superClass
C) class subclass < private superClass >
D) class subclass inherits private superClass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
19
Theoretically, clients do not need to see the _________ of classes from which they derive other classes.

A) Header files.
B) Source code.
C) Object code.
D) Interface.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 19 في هذه المجموعة.