Deck 13: Object-Oriented Programming: Polymorphism

ملء الشاشة (f)
exit full mode
سؤال
An abstract class will:

A) Have all zeros in its vtable.
B) Have at least one 0 in its vtable.
C) Share a vtable with a derived class.
D) Have fewer 0's in its vtable than concrete classes have.
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
Virtual functions must:

A) Be overridden in every derived class.
B) Be declared virtual in every derived class.
C) Be declared virtual in the base class.
D) Have the same implementation in every derived class.
سؤال
What mistake prevents the following class declaration from functioning properly as an abstract class?
Class Shape
{
Public:
Virtual double print) const;
Double area) const { return base * height; }
Private:
Double base;
Double height;
};

A) There are no pure virtual functions.
B) There is a non-virtual function.
C) private variables are being accessed by a public function.
D) Nothing, it functions fine as an abstract class.
سؤال
Problems using switch logic to deal with many objects of different types do not include:

A) Forgetting to include an object in one of the cases.
B) Having to update the switch statement whenever a new type of object is added.
C) Having to track down every switch statement to do an update of object types.
D) Not being able to implement separate functions on different objects.
سؤال
Concrete classes that inherit virtual functions but do not override their implementations:

A) Have vtables which are the same as those of their base classes.
B) Receive their own copies of the virtual functions.
C) Receive pointers to their base classes' virtual functions.
D) Receive pointers to pure virtual functions.
سؤال
Abstract classes do not necessarily have:

A) A 0 pointer in their vtable.
B) A virtual function prototype with the notation = 0.
C) Zero instances of their class.
D) Zero references to their class.
سؤال
Employee is a base class and HourlyWorker is a derived class, with a redefined non-virtual print function. Given the following statements, will the output of the two print function calls be identical?
HourlyWorker h;
Employee *ePtr = &h;
EPtr->print);
EPtr->Employee::print);

A) Yes.
B) Yes, if print is a static function.
C) No.
D) It would depend on the implementation of the print function.
سؤال
Which of the following would not be a member function that derived classes Fish, Frog and Bird should inherit from base class Animal and then provide their own definitions for, so that the function call can be performed polymorphically?

A) eat
B) sleep
C) move
D) flapWings
سؤال
Abstract classes:

A) Contain at most one pure virtual function.
B) Can have objects instantiated from them if the proper permissions are set.
C) Cannot have abstract derived classes.
D) Are defined, but the programmer never intends to instantiate any objects from them.
سؤال
Which of the following is not allowed?

A) Objects of abstract classes.
B) Multiple pure virtual functions in a single abstract class.
C) References to abstract classes.
D) Arrays of pointers to abstract classes.
سؤال
If objects of all the classes derived from the same base class all need to draw themselves, the draw) function would most likely be declared:

A) private
B) virtual
C) protected
D) friend
سؤال
The line:
Virtual double functionX) const = 0;
In a class definition indicates that the class is probably a:

A) Base class.
B) Derived class.
C) Protected class.
D) Library class.
سؤال
The C++ compiler makes objects take up more space in memory if they:

A) Are derived from base classes.
B) Have virtual functions.
C) Have only protected members.
D) Are referenced by pointers.
سؤال
Polymorphism is implemented via:

A) Member functions.
B) virtual functions and dynamic binding.
C) inline functions.
D) Non-virtual functions.
سؤال
The line:
Virtual double earnings) const = 0;
Appears in a class definition. You cannot deduce that:

A) All classes that directly inherit from this class will override this method.
B) This class is an abstract class.
C) Any concrete class derived from this class will have an earnings function.
D) This class will probably be used as a base class for other classes.
سؤال
Downcasting enables:

A) A derived-class object to be treated as a base-class object.
B) A base-class object to be treated as a derived-class object.
C) Making a base-class pointer into a derived-class pointer.
D) Making a derived-class pointer into a base -class pointer.
سؤال
Which of the following assignments would be a compilation error?

A) Assigning the address of a base-class object to a base-class pointer.
B) Assigning the address of a base-class object to a derived-class pointer.
C) Assigning the address of a derived-class object to a base-class pointer.
D) Assigning the address of a derived-class object to a derived-class pointer.
سؤال
Which of the following statements about virtual functions is false?

A) They allow the program to select the correct implementation at execution time.
B) They can use either static or dynamic binding, depending on the handles on which the functions are called.
C) They do not remain virtual down the inheritance hierarchy.
D) They can be called using the dot operator.
سؤال
The main difference between a pure virtual function and a virtual function is:

A) The return type.
B) The member access specifier.
C) That a pure virtual function cannot have an implementation.
D) The location in the class.
سؤال
Run-time type information can be used to determine:

A) A function's return type.
B) A function's argument type.
C) An object's type.
D) The number of arguments a function takes.
سؤال
Dynamic_cast is often used to:

A) Perform type checking for objects.
B) Convert pointers to strings.
C) Upcast pointers.
D) Downcast pointers.
سؤال
The __________ operator returns a reference to a __________ object:

A) typeid, type_info
B) typeinfo, type_id
C) typeid, data_type
D) typeinfo, type
سؤال
Virtual destructors must be used when:

A) The constructor in the base class is virtual.
B) delete is used on a base-class pointer to a derived-class object.
C) delete is used on a derived-class object.
D) A constructor in either the base class or derived class is virtual.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/23
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 13: Object-Oriented Programming: Polymorphism
1
An abstract class will:

A) Have all zeros in its vtable.
B) Have at least one 0 in its vtable.
C) Share a vtable with a derived class.
D) Have fewer 0's in its vtable than concrete classes have.
B
2
Virtual functions must:

A) Be overridden in every derived class.
B) Be declared virtual in every derived class.
C) Be declared virtual in the base class.
D) Have the same implementation in every derived class.
C
3
What mistake prevents the following class declaration from functioning properly as an abstract class?
Class Shape
{
Public:
Virtual double print) const;
Double area) const { return base * height; }
Private:
Double base;
Double height;
};

A) There are no pure virtual functions.
B) There is a non-virtual function.
C) private variables are being accessed by a public function.
D) Nothing, it functions fine as an abstract class.
A
4
Problems using switch logic to deal with many objects of different types do not include:

A) Forgetting to include an object in one of the cases.
B) Having to update the switch statement whenever a new type of object is added.
C) Having to track down every switch statement to do an update of object types.
D) Not being able to implement separate functions on different objects.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
5
Concrete classes that inherit virtual functions but do not override their implementations:

A) Have vtables which are the same as those of their base classes.
B) Receive their own copies of the virtual functions.
C) Receive pointers to their base classes' virtual functions.
D) Receive pointers to pure virtual functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
6
Abstract classes do not necessarily have:

A) A 0 pointer in their vtable.
B) A virtual function prototype with the notation = 0.
C) Zero instances of their class.
D) Zero references to their class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
7
Employee is a base class and HourlyWorker is a derived class, with a redefined non-virtual print function. Given the following statements, will the output of the two print function calls be identical?
HourlyWorker h;
Employee *ePtr = &h;
EPtr->print);
EPtr->Employee::print);

A) Yes.
B) Yes, if print is a static function.
C) No.
D) It would depend on the implementation of the print function.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following would not be a member function that derived classes Fish, Frog and Bird should inherit from base class Animal and then provide their own definitions for, so that the function call can be performed polymorphically?

A) eat
B) sleep
C) move
D) flapWings
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
9
Abstract classes:

A) Contain at most one pure virtual function.
B) Can have objects instantiated from them if the proper permissions are set.
C) Cannot have abstract derived classes.
D) Are defined, but the programmer never intends to instantiate any objects from them.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following is not allowed?

A) Objects of abstract classes.
B) Multiple pure virtual functions in a single abstract class.
C) References to abstract classes.
D) Arrays of pointers to abstract classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
11
If objects of all the classes derived from the same base class all need to draw themselves, the draw) function would most likely be declared:

A) private
B) virtual
C) protected
D) friend
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
12
The line:
Virtual double functionX) const = 0;
In a class definition indicates that the class is probably a:

A) Base class.
B) Derived class.
C) Protected class.
D) Library class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
13
The C++ compiler makes objects take up more space in memory if they:

A) Are derived from base classes.
B) Have virtual functions.
C) Have only protected members.
D) Are referenced by pointers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
14
Polymorphism is implemented via:

A) Member functions.
B) virtual functions and dynamic binding.
C) inline functions.
D) Non-virtual functions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
15
The line:
Virtual double earnings) const = 0;
Appears in a class definition. You cannot deduce that:

A) All classes that directly inherit from this class will override this method.
B) This class is an abstract class.
C) Any concrete class derived from this class will have an earnings function.
D) This class will probably be used as a base class for other classes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
16
Downcasting enables:

A) A derived-class object to be treated as a base-class object.
B) A base-class object to be treated as a derived-class object.
C) Making a base-class pointer into a derived-class pointer.
D) Making a derived-class pointer into a base -class pointer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
17
Which of the following assignments would be a compilation error?

A) Assigning the address of a base-class object to a base-class pointer.
B) Assigning the address of a base-class object to a derived-class pointer.
C) Assigning the address of a derived-class object to a base-class pointer.
D) Assigning the address of a derived-class object to a derived-class pointer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following statements about virtual functions is false?

A) They allow the program to select the correct implementation at execution time.
B) They can use either static or dynamic binding, depending on the handles on which the functions are called.
C) They do not remain virtual down the inheritance hierarchy.
D) They can be called using the dot operator.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
19
The main difference between a pure virtual function and a virtual function is:

A) The return type.
B) The member access specifier.
C) That a pure virtual function cannot have an implementation.
D) The location in the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
20
Run-time type information can be used to determine:

A) A function's return type.
B) A function's argument type.
C) An object's type.
D) The number of arguments a function takes.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
21
Dynamic_cast is often used to:

A) Perform type checking for objects.
B) Convert pointers to strings.
C) Upcast pointers.
D) Downcast pointers.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
22
The __________ operator returns a reference to a __________ object:

A) typeid, type_info
B) typeinfo, type_id
C) typeid, data_type
D) typeinfo, type
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
23
Virtual destructors must be used when:

A) The constructor in the base class is virtual.
B) delete is used on a base-class pointer to a derived-class object.
C) delete is used on a derived-class object.
D) A constructor in either the base class or derived class is virtual.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 23 في هذه المجموعة.