Midterm 2

Ace your homework & exams now with Quizwiz!

A function template's prefix contains __________ enclosed in angle brackets. a. one or more generic data types b. the function definition c. constant values d. the function's return type e. None of these

A

A virtual function is declared by placing the __________ key word in front of the return type in the base class's function declaration. a. virtual b. private c. public d. protected e. None of these

A

All type parameters defined in a function template must appear at least once in the a. function parameter list b. preprocessor directives c. function call d. type.h file e. None of these

A

Catch blocks serve as a. exception handlers b. receivers c. temporary variables d. permanent storage for trapped errors e. None of these

A

In a function template, the programmer substitutes __________ for __________. a. parameters, data types b. parameters, arguments c. arguments, parameters d. data types, parentheses e. None of these

A

The __________ constructor is called before the __________ constructor. a. base, derived b. derived, base c. public, private d. private, public e. None of these

A

The __________ members of a base class are never accessible to a derived class. a. private b. public c. protected d. All of these e. None of these

A

The __________ starts with the key word try and is followed by a block of code that executes any statement that might cause an exception to be thrown.. a. try block b. try/catch class c. try function d. catch function e. None of these

A

What does the word class indicate in the following statement? template < class T > a. class is a key word that is used to precede the type parameter. b. It indicates that a class is being derived from an existing class named T. c. It indicates that a class named T is being derived from a class named template. d. A class named T will automatically be created by the compiler. e. None of these

A

When a derived class has two or more base classes, the situation is called a. multiple inheritance b. multiplicity c. polymorphism d. encapsulation e. None of these

A

When the __________ operator fails to allocate memory, C++ throws a bad_alloc exception. a. new b. alloc c. catch d. None of these

A

Which is the derived class in the following statement? class Car : protected Vehicle a. Car b. Vehicle c. protected d. There is no way to tell. e. None of these

A

Which of the following is commonly used to extend a class or to give it additional capabilities? a. inheritance b. privacy c. the constructor d. the destructor e. None of these

A

Select all that apply. The base class access specification determines how __________ members in the base class may be accessed by derived classes. a. private b. public c. constructed d. protected e. None of these

A,B,D

Select all that apply. In an inheritance situation, the new class that you create from an existing class is known as the a. derived class b. inheritor c. child class d. parental class e. None of these

A,C

Select all that apply. Which of the following constructors cannot be inherited through constructor inheritance? a. the default constructor b. the virtual constructor c. the move constructor d. the copy constructor e. the grand constructor

A,C,D

In the following code, which statement is the throw point? double divide(int numer, int denom) { if (denom == 0) throw "ERROR: Cannot divide by zero.\n"; else return static_cast<double>(numer)/denom; } a. if (denom == 0) b. throw "ERROR: Cannot divide by zero.\n"; c. return static_cast<double>(numer)/denom; d. There is no throw point because there is no try block. e. None of these

B

Multiple inheritance is when a __________ class has __________ base classes. a. base, no b. derived, two or more c. derived, no d. compound, more than two e. None of these

B

Objects are created from abstract data types that encapsulate __________ and __________ together. a. numbers, characters b. data, functions c. addresses, pointers d. integers, floating-point numbers e. None of these

B

The __________ destructor is called before the __________ destructor. a. base, derived b. derived, base c. public, private d. private, public e. None of these

B

The term __________ means the ability to take many forms. a. inheritance b. polymorphism c. member function d. encapsulation e. None of these

B

To handle an exception that has been thrown, a program must have a(n) a. throw function b. try/catch construct c. fatal error d. unrecoverable error e. None of these

B

What is being protected in the following statement? class Car : protected Vehicle a. derived class functions b. base class members c. derived class data d. future inherited classes e. None of these

B

When an error occurs, an exception is a. created b. thrown c. passed d. ignored e. None of these

B

Which is the base class in the following statement? class Car : public Vehicle a. Car b. Vehicle c. public d. class e. None of these

B

The following statement allows the __________ members of the Car class to access __________ members of the Vehicle class. class Car : public Vehicle a. private, private b. public, private c. protected, private d. public, protected e. None of these

E

When more than one class is derived from a base class, the situation is called a. polymorphism b. multiplicity c. population d. encapsulation e. None of these

E

A derived class may not have any classes derived from it.

F

A destructor function can have zero to many parameters.

F

A generic function that can work with any data type is called an exception template.

F

A member function of a derived class may not have the same name as a member function of a base class.

F

A program may not contain both a "regular" version of a function and a template version of the function.

F

Class objects can be defined prior to the class declaration.

F

If an exception is not caught, it is stored for later use.

F

In C++11, using constructor inheritance, it is possible for any of the base class's constructors to be inherited.

F

In an inheritance situation, you may not pass arguments to a base class constructor.

F

In-place member initialization no longer is available in C++11.

F

More than one destructor function may be defined for a class.

F

The constructor function may not accept arguments.

F

The try block of a try/catch construct is used to display the definition of an exception parameter.

F

The try/catch/throw construct is able to handle only one type of exception in a try block.

F

There is no difference between declaring an object of an ordinary class and an object of a template class.

F

While a class's member functions may be overloaded, the constructor cannot be overloaded.

F

You must declare all data members of a class before you declare member functions.

F

You must use the private access specification for all data members of a class.

F

When an object is defined without an argument list for its constructor, the compiler automatically calls the object's default constructor.

T

When arguments must be passed to the base class constructor, they are passed from the derived class constructor's header line.

T

When using smart pointers to dynamically allocate objects in C++ 11, it is unnecessary to delete the dynamically allocated objects because the smart pointer will automatically delete them.

T

Whereas object-oriented programming centers on the object, procedural programming centers on functions.

T

You can use the technique known as a member intialization list to initialize members of a class.

T

More than one constructor function may be defined for a class.

T

Pointers to a base class may be assigned the address of a derived class object.

T

The line containing a throw statement is known as the throw point.

T

Using a function template requires less code than overloading a function.

T

Static binding occurs when the compiler binds a function call with the function call that resides in the same class as the call itself.

T

Arguments are passed to the base class by the __________ class __________ function. a. derived, constructor b. derived, destructor c. base, constructor d. base, destructor e. None of these

E

The base class access specification can be viewed as a filter that base class members must pass through when becoming inherited members of a derived class.

T

Arguments are passed to the base class destructor by the __________ class __________ function. a. derived, constructor b. derived, destructor c. base, constructor d. base, destructor e. None of these

E

In OOP programming, __________ allows you to create new classes based on existing classes. a. polymorphism b. inheritance c. function overloading d. the copy constructor e. None of these

B

An actual instance of the function is created in memory when the compiler encounters a. the template prefix b. a call to the template function c. a try block d. a catch block e. None of these

B

If an exception is thrown by a member function of a class object, the class __________ is called. a. constructor b. destructor c. catcher d. handler e. None of these

B

In object-oriented programming, the object encapsulates both the data and the functions that operate on the data.

T

A function template prefix is placed before the function header while a class template prefix is placed a. following the public: access specification b. following the private: access specification c. before the class declaration d. before the class constructor function header e. None of these

C

A generic function that can work with any data type is a a. function argument b. function parameter c. function template d. member function e. None of these

C

A virtual function is a function that expects to be __________ in a derived class. a. ignored b. called frequently c. overridden d. private e. None of these

C

C++11 introduced the __________ key word to help prevent subtle errors when overriding virtual functions. a. const b. final c. override d. virtual e. None of these

C

Given the following code, what will happen if the value of denom is 0? double divide(int numer, int denom) { if (denom == 0) throw "ERROR: Cannot divide by zero.\n"; else return static_cast<double>(numer)/denom; } a. Nothing will happen because there is no catch block. b. The program will display ERROR: Cannot divide by zero.and then move to the statement following the if/else block. c. The program will display ERROR: Cannot divide by zero.and then halt. d. There is no throw point because there is no try block. e. None of these

C

If you want to catch a bad_alloc exception in a program, you should include a. #include <iostream> b. #include <alloc> c. #include <new> d. None of these

C

Polymorphism is when __________ in a class hierarchy perform differently, depending on which object performs the call. a. base class constructors b. derived class constructors c. member functions d. derived class destructors e. None of these

C

Protected members of a base class are like __________, but they may be accessed by derived classes. a. constructor functions b. static members c. private members d. public members e. None of these

C

Select all that apply. The base class's __________ affects the way its members are inherited by the derived class. a. name b. return data type c. access specification d. construction e. None of these

C

The beginning of a function template is marked by a a. return type b. parameter list c. template prefix d. semicolon e. None of these

C

The try block is immediately followed by one or more a. errors b. error messages c. catch blocks d. throw blocks e. None of these

C

What does the T represent in the following statement? template < class T > a. the name of the function template b. T stands for Template c. a generic data type that is used in a function template d. the int data type e. None of these

C

When member functions behave differently depending on which object performed the call, this is an example of a. chaos theory b. virtual insubordination c. polymorphism d. encapsulation e. None of these

C

When the compiler binds a member function call with the version of the function that resides in the same class as the call itself, it is considered a. local binding b. safe binding c. static binding d. dynamic binding e. None of these

C

When you derive a class from an existing class, you __________ add new data and functions. a. never b. must c. may d. None of these

C

Which of the following is used to signal errors or unexpected results that happen as a program runs? a. virtual functions b. destructors c. exceptions d. templates e. None of these

C

A C++ class is similar to a(n) a. inline function b. header file c. library function d. structure e. None of these

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

D

A(n) __________ is a value or an object that signals an error. a. destructor b. template c. throw d. exception e. None of these

D

A(n) __________ is used in a function template to specify a generic data type. a. dummy variable b. exception c. catch block d. type parameter e. None of these

D

An exception thrown from outside a try block will a. be caught outside the catch block b. be caught inside the catch block c. remain inside the throw block d. cause the program to abort execution e. None of these

D

Class templates allow you to create one general version of a class without having to a. write any code b. use member functions c. use private members d. duplicate code to handle multiple data types e. None of these

D

Functions that are dynamically bound by the compiler are __________ functions. a. constructor b. destructor c. static d. virtual e. None of these

D

How much memory is reserved for a function template? a. four bytes b. It depends on the size of the template. c. two bytes d. no memory e. None of these

D

In OOP terminology, an object's member variables are often called its __________ and its member functions can be referred to as its behaviors or its __________. a. values, morals b. data, activities c. attributes, activities d. attributes, methods e. None of these

D

Multiple inheritance opens the opportunity for a derived class to have ___________ members. a. dynamic b. private c. public d. ambiguous e. None of these

D

The compiler performs __________ on virtual functions. a. local binding b. additional error checking c. static binding d. dynamic binding e. None of these

D

A derived class may become a base class if another class is derived from it.

T

A private member function is useful for tasks that are internal to the class but it is not directly called by statements outside the class.

T

C++11 provides a way for a derived class to inherit some of the base class's constructors.

T

Constructor functions are often used to allocate memory that will be needed by the object.

T

Destructor functions are often used to free memory that was allocated by the object.

T

Exceptions are used to signal errors or unexpected results that occur when a program is running.

T

Function templates allow you to write a single function definition that works with many data types.

T

If an exception is not caught, the program will abort execution.

T

If you do not declare a destructor function, the compiler will furnish one automatically.

T

In C++11, if a derived class attempts to override a final member function, the compiler generates an error.

T

More than one class may be derived from a base class.

T


Related study sets

The Second Industrial Revolution, Electricity Part 1

View Set

Chapter 3: Licensing and Certification

View Set

Key Terms (TEAS Mathematics Section) 2021-2022

View Set

Chapter 24 MC Quiz - World Civilizations II

View Set

Chapter 15 Personal Law Vocabulary Terms

View Set

Fundamentals Test 2 Prep U Urinary Elimination

View Set

Chapter 42: Nursing Care of a Child with an Alteration In Bowel Elimination/GI Disorder

View Set

APES 5.8- Impacts of Overfishing and 5.16 - Aquaculture

View Set