[CSCI 156] Test 3
A generic function that can work with any data type is a A. function template B. none of these C. member function D. function argument E. function parameter
Answer Key:A
C++ requires that a copy constructor's parameter be a(n) A. reference object B. floating-point data type C. integer data type D. none of these E. pointer variable
Answer Key:A
Catch blocks serve as A. exception handlers B. receivers C. none of these D. temporary variables E. permanent storage on the heap for trapped variables
Answer Key:A
If you do NOT furnish a ________, a default one will be provided by the compiler. A. all of these B. none of these C. copy constructor D. constructor E. destructor
Answer Key:A
The ________ members of a base class are never accessible to a derived class. A. private B. none of these C. protected D. all of these E. public
Answer Key:A
When you derive a class from an existing class, you ________ add new data and functions. A. may B. none of these C. must D. never
Answer Key:A
Which of the following is used to signal errors or unexpected results that happen as a program runs? A. exceptions B. templates C. virtual functions D. none of these E. destructors
Answer Key:A
An exception thrown from outside a try block will A. remain inside the throw block B. cause the program to abort execution C. be caught outside the catch block D. be caught inside the catch block E. none of these
Answer Key:B
The ________ constructor is called before the ________ constructor. A. private, public B. base, derived C. derived, base D. none of these
Answer Key:B
What does the T represent in the following statement? Template <class T> A. the T stands for template B. a generic data type used in the template C. none of these D. the int data type E. the name of the function template
Answer Key:B
What is being protected in the following statement? class Car : protected Vehicle A. derived class data B. base class members C. none of these D. derived class functions E. future inherited classes
Answer Key:B
When member functions behave differently depending on which object performed the call, this is an example of A. none of these B. polymorphism C. encapsulation D. chaos theory E. virtual insubordination
Answer Key:B
When more than one class is derived from a base class, the situation is called A. encapsulation B. none of these C. population D. multiplicity E. polymorphism
Answer Key:B
When objects contain pointers, it is a good idea to create an explicit ________ function. A. static constructor B. copy constructor C. none of these D. inline constructor E. destructor
Answer Key:B
Which is the derived class in the following statement? class Car : protected Vehicle A. protected B. Car C. Vehicle D. none of these E. there is no way to tell
Answer Key:B
In a function template, the programmer substitutes ________ for ________. A. arguments, parameters B. parameters, arguments C. parameters, data types D. none of these E. data types, parentheses
Answer Key:C
When the ________ operator fails to allocate memory, C++ throws a bad_alloc exception. A. catch B. malloc C. new D. none of these E. alloc
Answer Key:C
(1point) It is a good idea to make a copy constructor's parameters ________ by specifying the ________ key word in the parameter list. A. none of these B. inline, inline C. static, static D. constant, const E. global, global
Answer Key:D
A ________ of a base class expects to be overridden in a derived class. A. constructor function B. destructor function C. static function D. virtual function E. none of these
Answer Key:D
If an exception is thrown by a member function of a class object, the class ________ is called. A. handler B. catcher C. constructor D. destructor E. none of these
Answer Key:D
The following statement allows the ________ members of the Car class to access ________ members of the Vehicle class. class Car : public Vehicle A. protected, private B. private, private C. public, private D. none of these E. public, protected
Answer Key:D
What does the word class indicate in the following statement? template <class T> A. It indicates that a class is being derived from an existing class named T B. A class named T will automatically be created by the compiler C. It indicates that a class named T is being derived from a class named template D. class is a keyword that is used to precede the type parameter E. none of these
Answer Key:D
Arguments are passed to the base class destructor by the ________ class ________ function. A. derived, constructor B. base, destructor C. derived destructor D. base, constructor E. none of these
Answer Key:E
In OOP programming, ________ allows you to create new classes based on existing classes. A. polymorphism B. none of these C. the copy constructor D. function overloading E. inheritance
Answer Key:E
Protected members of a base class are like ________, but they may be accessed by derived classes. A. public members B. constructor functions C. static members D. none of these E. private members
Answer Key:E
To handle an exception that has been thrown, a program must have a(n) a. throw function declared and defined in the same file the program is written b. try/catch construct c. fatal error d. unrecoverable error e. none of these
Answer Key:E