Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Chapter 16 Starting out with C++ Exceptions Templates and the Standard Template


 

Download  file with the answers

Not a member!
Create a FREE account here to get access and download this file with answers


 

Chapter Sixteen

MULTIPLE CHOICE

1. These are used to signal errors or unexpected events that occur while a program is running.
a. Virtual functions
b. Destructors
c. Exceptions
d. Templates
e. None of these

2. The _______ starts with the keyword try, and is followed by a block of code executing any statements 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

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

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

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

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

7. 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

8. 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

9. In the following statement

template < class T >

what does T represent?
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

10. 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

11. In the following statement

template

what does the word class indicate?
a. class is a keyword that is used to precede the type parameter T
b. you are deriving a class from an existing class called T
c. you are deriving a class called T from a class called template
d. a class named T will automatically be created by the compiler
e. None of these

12. Two types of container classes in the STL are:
a. sequence and associative
b. box and cylinder
c. array and struct
d. constant and literal
e. None of these

13. A(n) _________ is like a pointer. It is used to access the individual data elements in a container.
a. element access operator
b. subscript indicator
c. global data finder
d. iterator
e. None of these

14. The three sequence container objects provided by the STL are:
a. set, multiset, map
b. vector, deque, list
c. map, list, array
d. multimap, map, multilist
e. None of these

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

16. 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

17. 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

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

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

20. How much memory is reserved for a function template?
a. four bytes
b. eight bytes
c. two bytes
d. no memory
e. None of these

21. 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

22. A function template’s prefix contains __________ enclosed in angled 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

23. 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

24. A function template prefix is placed before the function header. 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

25. The most important data structures in the STL are _______ and _________.
a. arrays, structs
b. lists, groups
c. containers, iterators
d. templates, prototypes
e. None of these

26. A(n)__________ is a class that stores data and organizes it in some fashion.
a. iterator
b. container
c. template
d. box
e. None of these

27. An associative container uses these to access elements rapidly.
a. data
b. functions
c. keys
d. complex sort algorithms
e. None of these

28. Types of iterators are
a. input and output
b. forward and bidirectional
c. random-access
d. All of these
e. None of these

29. The algorithms provided by the STL are implemented as _____________, and perform various operations on elements of containers.
a. virtual functions
b. function templates
c. global variables
d. private data members
e. None of these

TRUE/FALSE

1. True/False: If an exception is not caught, it is stored for later use.

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

3. True/False: A program may not contain both a “regular” version of a function and a template version of the function.

4. True/False: There is no difference between declaring an object of an ordinary class and an object of a template class.

5. True/False: The Standard Template Library (STL) contains templates for useful algorithms and data structures.

6. True/False: A sequence container organizes data in a sequential fashion, similar to an array.

7. True/False: The line containing a throw statement is known as the throw point.

8. True/False: Function templates allow you to write a single function definition that works with many different data types.

9. True/False: Using a function template requires less code than overloading a function.

10. True/False: When you declare an iterator to work with a container, the compiler automatically chooses the right type.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!