1. When a throw statement is executed, a. execution of the try block stops. b. e
ID: 3581580 • Letter: 1
Question
1. When a throw statement is executed,
a. execution of the try block stops.
b. execution of the throw block stops.
c. the program always exits.
d. execution of the catch block stops.
2. The parameter in the catch statement
a. identifies what type of exceptions are caught.
b. identifies the different number of exceptions that can be caught.
c. makes the catch block a function.
d. must always be an e.
3. The throw statement is enclosed in
a. a catch block.
b. a throw block.
c. a try block.
d. quotes.
4. The following catch statement: catch (...)
a. is illegal.
b. catches only numeric exceptions,
c. catches all exceptions.
d. should be the first catch block of multiple catch statements are present.
5. The following class definition: class MyError{ }
a. has no member functions or member data.
b. has only a default constructor.
c. is illegal.
d. A & B.
6. If a function throws an exception,
a. it must be caught in that function.
b. it may be caught in that function.
c. it causes a syntax error.
d. it can only be a non-numeric exception.
7. If the following function will throw a string exception, then: void myFunction();
a. the function definition and declaration should have a throw list
b. the function definition, but not the declaration should have a throw list
c. the function should have an empty throw list.
d. all of the above.
8. Which of the following would be a good reason for using inherited exception classes?
a. a base class exception can be passed to an exception parameter of the derived class.
b. a derived class exception can be passed to an exception parameter of the base class.
c. a base class exception parameter can be passed any type of exception.
d. all of the above.
9. You should use exception handling
a. in all your programs.
b. only when you cannot handle the exception with simpler control structure.
c. only when you use classes.
d. in every function.
Explanation / Answer
1. a. execution of the try block stops.
2. a. identifies what type of exceptions are caught.
3. a. a catch block.
4. c. catches all exceptions.
5. d. A & B.
6. b. it may be caught in that function.
7. d. all of the above.
8. d. all of the above.
9. b. only when you cannot handle the exception with simpler control structure.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.