Deck 4: Inheritance and Class Hierarchies
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/25
العب
ملء الشاشة (f)
Deck 4: Inheritance and Class Hierarchies
1
The objects of a derived class __________ the original data fields and members of a base class.
inherit
2
Classes can be arranged in a hierarchy, with a top-level __________ class.
base
3
Objects further down the hierarchy are more complex and less general than those further up.
True
4
The __________ relationship between classes means that every instance of one class is or may be associated with one or more instances of the other class (but not necessarily the other way around).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
5
A Ford Model-T automobile is in a "has-a" relationship with __________.
A) automobiles
B) antique automobiles
C) a Rolls Royce Silver Ghost
D) an engine
A) automobiles
B) antique automobiles
C) a Rolls Royce Silver Ghost
D) an engine
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
6
According to the inheritance structure defined by the code fragment below, an Airplane is a kind of Jet_Plane.
class Jet_Plane : public Airplane {
private:
int num_engines;
Jet_Engine jets[4];
// ...
};
class Jet_Plane : public Airplane {
private:
int num_engines;
Jet_Engine jets[4];
// ...
};
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
7
If the execution of any constructor in a derived class does not invoke a base class constructor, C++ automatically invokes the no-parameter constructor for the __________ class.
A) sub
B) base
C) child
D) subordinate
A) sub
B) base
C) child
D) subordinate
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
8
In general, it is better to use __________ visibility, because derived classes may be written by different programmers, and it is always a good practice to restrict and control access to the base-class data fields.
A) protected
B) public
C) package
D) private
A) protected
B) public
C) package
D) private
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
9
Member functions generally have __________ visibility, so we should be able to access a member function that is inherited.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
10
Having multiple member functions with the same name but different signatures in a class is called member function __________.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
11
Suppose two Clock class functions named get_military_time use the following headers:
Std::string get_military_time (int hours, int minutes);
Std::string get_military_time (int hours, int minutes, int seconds);
The get_military__time member function is said to be __________.
A) overloaded
B) overridden
C) downcast
D) extended
Std::string get_military_time (int hours, int minutes);
Std::string get_military_time (int hours, int minutes, int seconds);
The get_military__time member function is said to be __________.
A) overloaded
B) overridden
C) downcast
D) extended
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
12
If a member function is declared __________, then when it is called through a pointer (or reference) variable the actual member function will be determined at run time and based on the type of the object pointed to (or referenced).
A) public
B) private
C) virtual
D) protected
A) public
B) private
C) virtual
D) protected
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
13
The C++ compiler can assign object addresses to pointers at program run-time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
14
A(n) __________ function is a virtual function that is declared but for which no body (definition) is provided.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following statements is a valid abstract member function declaration for class Food?
A) abstract double percent_protein();
B) abstract double percent_protein() const = 0;
C) virtual double percent_protein();
D) virtual double percent_protein() const = 0;
A) abstract double percent_protein();
B) abstract double percent_protein() const = 0;
C) virtual double percent_protein();
D) virtual double percent_protein() const = 0;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
16
A pointer variable (l-value) that is of type pointer-to- __________ class may point to a derived object (r-value).
A) sub
B) child
C) base
D) derived
A) sub
B) child
C) base
D) derived
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
17
Given that the Lap_Top class derives from Computer class, which of the following pointer declarations is legal?
A) Lap_Top* a_laptop = new Computer( ... );
B) Computer* a_computer = new Lap_Top( ... );
C) Lap_Top* a_laptop = Computer( ... );
D) *a_computer = new LapTop( ... );
A) Lap_Top* a_laptop = new Computer( ... );
B) Computer* a_computer = new Lap_Top( ... );
C) Lap_Top* a_laptop = Computer( ... );
D) *a_computer = new LapTop( ... );
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
18
If you dynamically cast a pointer to a lower type object, the lower type object is promoted to a higher type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
19
Complete the header for class Artist, which inherits from both class Musician and class Writer.
class Artist __________
class Artist __________
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
20
__________ is a process that resolves name conflicts by collecting common data fields and member functions into a common base class.
A) Overloading
B) Refactoring
C) Overriding
D) Casting
A) Overloading
B) Refactoring
C) Overriding
D) Casting
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
21
__________ are used to group collections of declarations into a functional unit.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
22
At the top of the level of the namespace hierarchy resides the global namespace, whose name is effectively the __________ string.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
23
The statement __________ creates an object of type stack as defined in the optimize namespace.
Class stack { ... }; // Defined in the global namespace
Namespace optimize {
Class stack { ... }; // Defined in the optimize namespace
}
A) stack aStack;
B) std::stack aStack;
C) optimize aStack;
D) optimize::stack aStack;
Class stack { ... }; // Defined in the global namespace
Namespace optimize {
Class stack { ... }; // Defined in the optimize namespace
}
A) stack aStack;
B) std::stack aStack;
C) optimize aStack;
D) optimize::stack aStack;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
24
To access a single name from the namespace in which it was declared requires a using __________ .
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck
25
Private visibility is for members of a class that should not be accessible to anyone but the class, not even classes that extend it.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 25 في هذه المجموعة.
فتح الحزمة
k this deck