Deck 11: Object-Oriented Programming: Inheritance
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/17
العب
ملء الشاشة (f)
Deck 11: Object-Oriented Programming: Inheritance
1
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.
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.
D
2
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.
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.
A
3
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.
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.
D
4
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
A) protected, private, public
B) private, protected, public
C) private, public, protected
D) protected, public, private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
5
Assuming the following is the beginning of the constructor definition for class BasePlus-CommissionEmployee which inherits from class Point: BasePlusCommissionEmployee::BasePlusCommissionEmployee(string first,
String last, string ssn, double sales, double rate, double salary)
: CommissionEmployee(first, last, ssn, sales, rate)
The line beginning with a colon(:)
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.
String last, string ssn, double sales, double rate, double salary)
: CommissionEmployee(first, last, ssn, sales, rate)
The line beginning with a colon(:)
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
6
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
A) protected, private
B) public, private
C) protected, protected
D) public, protected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
7
Which of the following is most likely a base class of the other three?
A) automobile.
B) convertible.
C) miniVan.
D) sedan.
A) automobile.
B) convertible.
C) miniVan.
D) sedan.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
8
The is-a relationship represents.
A) Composition.
B) Inheritance.
C) Information Hiding.
D) A friend.
A) Composition.
B) Inheritance.
C) Information Hiding.
D) A friend.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
10
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) 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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
11
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.
A) All forms of inheritance are is-a relationships.
B) Only public and private.
C) Only public and protected.
D) Only public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
12
Assuming the definition, class BasePlusCommissionEmployee : 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.
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
13
Which of the following is not a kind of inheritance in C++?
A) public.
B) private.
C) static.
D) protected.
A) public.
B) private.
C) static.
D) protected.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
14
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
D) class subclass inherits private superClass
A) class subclass : private superClass
B) class subclass :: private superClass
C) class subclass
D) class subclass inherits private superClass
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following statements about inheriting base class constructors is false?
A) To inherit a base class's constructors, you write the following line of code in the derived class definition (BaseClass is the base class's name):
Using BaseClass::BaseClass;
B) If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.
C) By default, each inherited constructor has the same access level (public, protected or private) as its corresponding base-class constructor.
D) If the derived class does not explicitly define constructors, the compiler generates a default constructor in the derived class-even if it inherits other constructors from its base class.
A) To inherit a base class's constructors, you write the following line of code in the derived class definition (BaseClass is the base class's name):
Using BaseClass::BaseClass;
B) If an inherited base-class constructor has default arguments, the line of code in Part (a) causes the compiler to generate a derived-class constructor with the same default arguments.
C) By default, each inherited constructor has the same access level (public, protected or private) as its corresponding base-class constructor.
D) If the derived class does not explicitly define constructors, the compiler generates a default constructor in the derived class-even if it inherits other constructors from its base class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
16
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.
A) Airplanes.
B) Geometric shapes.
C) Animals.
D) Prime numbers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck
17
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.
A) Base class, base class.
B) Derived class, base class.
C) Base class, derived class.
D) Derived class, public.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 17 في هذه المجموعة.
فتح الحزمة
k this deck