Deck 10: Exception Handling

Full screen (f)
exit full mode
Question
When illegal division by 0 takes place, an exception object is not created automatically by the object-oriented language application.
Use Space or
up arrow
down arrow
to flip the card.
Question
A(n) ____ is an unexpected or error condition that occurs while a program is running.

A)error handle
C)exception
B)program error
D)program exit
Question
____ is thrown when an object reference does not correctly refer to a created object.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
Question
When you create a segment of code in which something might go wrong, you place the code in an error block.
Question
A ____ is a segment of code that can handle an exception that might be thrown by the try block that precedes it.

A)catch method
C)catch block
B)throw block
D)throw statement
Question
A system of passing exceptions through the chain of calling methods has great advantages because it allows methods to handle exceptions wherever the programmer has decided it is most appropriate.
Question
The object-oriented techniques to manage errors, such as dividing a value by 0, comprise the group of methods known as ____.

A)exception handling
C)exception processing
B)error handling
D)error processing
Question
When a method in an object-oriented program causes an exception, such as dividing by 0, the method ____.

A)throws the error
C)catches the exception
B)stops the exception
D)throws the exception
Question
You can create your own exceptions.
Question
Using a traditional error-handling method to avoid dividing by 0 prevents the error and makes the method more flexible.
Question
____ is thrown when an arithmetic operation produces a result for which the value is greater than the assigned memory location can accommodate.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
Question
A ____ is one that sends an exception object out of a method so it can be handled elsewhere.

A)catch statement
C)catch block
B)throw method
D)throw statement
Question
In object-oriented terminology, you "____" a segment of code that might cause an error.

A)try
C)throw
B)catch
D)observe
Question
When a program throws an exception, you always have to deal with it.
Question
Dividing by 0 is an error in every programming language because it is an operation that is not defined mathematically.
Question
Probably the most often used error-handling solution before object-oriented programming was to make a decision before working with a potentially error-causing value.
Question
A catch block consists of four different elements: the keyword catch, followed by parentheses that contain an exception type and identifier, statements that take action to handle the error condition, an endcatch statement, and a return statement.
Question
In Java, an ArithmeticException is a type of ____.

A)Error
C)RuntimeError
B)Exception
D)OverflowException
Question
You can only place one statement within each try block.
Question
____ is thrown when you attempt to store an object that is the wrong data type in an array.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
Question
Many well-designed programs that try code do not include any catch blocks; instead, they contain only ____.

A)release pairs
C)try-finally pairs
B)try pairs
D)finally pairs
Question
By inheriting from the Exception class, you gain access to methods contained in the ____.

A)derived class
C)child class
B)subclass
D)parent class
Question
If method A calls method B and method B throws an exception, which method will catch the exception, assuming all methods have a catch block?

A)method B
C)the operating system
B)method A
D)none of the above
Question
Methods are flexible partly because they are ____.

A)contained
C)short
B)compact
D)reusable
Question
An ____ indicates exception types that might be thrown in the method header.

A)exception clause
C)exception method clause
B)exception specification clause
D)error specification clause
Question
Exceptions can be particularly useful when you throw them from ____, which do not have a return type, so they have no other way to send information back to the calling method.

A)methods
C)constructors
B)classes
D)finally blocks
Question
When you create an exception, it is conventional to end its name with ____.

A)EClass
C)Error
B)Exception
D)Exc
Question
The block of code that processes an error in exception handling "____."

A)throws the exception
C)holds the exception
B)catches the exception
D)tries the exception
Question
To create your own throwable Exception, you usually extend a built-in ____ class.

A)ProblemHandle
C)Exception
B)Problem
D)Error
Question
A(n) ____ statement indicates the end of the catch block in the pseudocode.

A)finalcatch
C)endcatch
B)finally
D)stop
Question
As opposed to exception handling, program ____________________ is abrupt and unforgiving.
Question
The ____ block is used when the program uses data files that must be closed.

A)release
C)resource
B)finally
D)discharge
Question
The memory location known as the ____ is where the computer stores the list of method locations to which the system must return.

A)method stack
C)call stack
B)location stack
D)store location
Question
When appropriate, specialized ____ classes provide an elegant way for you to handle error situations.

A)Exception
C)Constructor
B)Error
D)Event
Question
A(n) ____________________ block includes any number of statements that might cause exceptions.
Question
____ statements are program statements that can never execute under any circumstances.

A)Inaccessible code
C)Remote code
B)Unreachable code
D)Isolated code
Question
A catch block has no return type and ____ be called directly.

A)cannot
C)can sometimes
B)can
D)can always
Question
Each ____________________ block can catch only one type of exception.
Question
Object-oriented ____________________ provides a more elegant solution for handling error conditions than in previous procedural approaches.
Question
You can handle ____________________ either in a traditional manner or in an object-oriented manner.
Question
Only the first ____________________ statement in a try block throws an exception.
Question
When you include a(n) ____________________ block, you are assured that the finally statements will execute before the method is abandoned, even if the method closes prematurely.
Question
The ____________________ is where the computer stores the list of method locations to which the system must return.
Question
____________________ code statements are program statements that can never execute under any circumstances.
Question
When an exception is created and ____________________, the catch block that follows and contains an Exception argument executes.
Question
To create your own throwable exception, you usually ____________________ a built-in Exception class.
Question
When you create your own exceptions by inheriting from a built-in Exception class, you gain access to methods contained in the ____________________ class, such as those that display a default message describing an exception and that display the stack trace.
Question
Programmers sometimes call a situation in which nothing goes wrong the ____________________.
Question
When a division by 0 happens during the execution of a method, the application that calls the method typically terminates, control returns to the operating system, and a(n) ____________________ is generated.
Question
In some languages, if an exception is thrown from one method and caught by another, you must write a(n) ____________________.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 10: Exception Handling
1
When illegal division by 0 takes place, an exception object is not created automatically by the object-oriented language application.
False
2
A(n) ____ is an unexpected or error condition that occurs while a program is running.

A)error handle
C)exception
B)program error
D)program exit
C
3
____ is thrown when an object reference does not correctly refer to a created object.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
C
4
When you create a segment of code in which something might go wrong, you place the code in an error block.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
A ____ is a segment of code that can handle an exception that might be thrown by the try block that precedes it.

A)catch method
C)catch block
B)throw block
D)throw statement
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A system of passing exceptions through the chain of calling methods has great advantages because it allows methods to handle exceptions wherever the programmer has decided it is most appropriate.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
The object-oriented techniques to manage errors, such as dividing a value by 0, comprise the group of methods known as ____.

A)exception handling
C)exception processing
B)error handling
D)error processing
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
When a method in an object-oriented program causes an exception, such as dividing by 0, the method ____.

A)throws the error
C)catches the exception
B)stops the exception
D)throws the exception
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
You can create your own exceptions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Using a traditional error-handling method to avoid dividing by 0 prevents the error and makes the method more flexible.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
____ is thrown when an arithmetic operation produces a result for which the value is greater than the assigned memory location can accommodate.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
A ____ is one that sends an exception object out of a method so it can be handled elsewhere.

A)catch statement
C)catch block
B)throw method
D)throw statement
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
In object-oriented terminology, you "____" a segment of code that might cause an error.

A)try
C)throw
B)catch
D)observe
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
When a program throws an exception, you always have to deal with it.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Dividing by 0 is an error in every programming language because it is an operation that is not defined mathematically.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
Probably the most often used error-handling solution before object-oriented programming was to make a decision before working with a potentially error-causing value.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
A catch block consists of four different elements: the keyword catch, followed by parentheses that contain an exception type and identifier, statements that take action to handle the error condition, an endcatch statement, and a return statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
In Java, an ArithmeticException is a type of ____.

A)Error
C)RuntimeError
B)Exception
D)OverflowException
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
You can only place one statement within each try block.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
____ is thrown when you attempt to store an object that is the wrong data type in an array.

A)IndexOutOfRangeException
C)NullReferenceException
B)ArrayTypeMismatchException
D)OverflowException
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Many well-designed programs that try code do not include any catch blocks; instead, they contain only ____.

A)release pairs
C)try-finally pairs
B)try pairs
D)finally pairs
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
By inheriting from the Exception class, you gain access to methods contained in the ____.

A)derived class
C)child class
B)subclass
D)parent class
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
If method A calls method B and method B throws an exception, which method will catch the exception, assuming all methods have a catch block?

A)method B
C)the operating system
B)method A
D)none of the above
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Methods are flexible partly because they are ____.

A)contained
C)short
B)compact
D)reusable
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
An ____ indicates exception types that might be thrown in the method header.

A)exception clause
C)exception method clause
B)exception specification clause
D)error specification clause
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Exceptions can be particularly useful when you throw them from ____, which do not have a return type, so they have no other way to send information back to the calling method.

A)methods
C)constructors
B)classes
D)finally blocks
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
When you create an exception, it is conventional to end its name with ____.

A)EClass
C)Error
B)Exception
D)Exc
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
The block of code that processes an error in exception handling "____."

A)throws the exception
C)holds the exception
B)catches the exception
D)tries the exception
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
To create your own throwable Exception, you usually extend a built-in ____ class.

A)ProblemHandle
C)Exception
B)Problem
D)Error
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
A(n) ____ statement indicates the end of the catch block in the pseudocode.

A)finalcatch
C)endcatch
B)finally
D)stop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
As opposed to exception handling, program ____________________ is abrupt and unforgiving.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The ____ block is used when the program uses data files that must be closed.

A)release
C)resource
B)finally
D)discharge
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
The memory location known as the ____ is where the computer stores the list of method locations to which the system must return.

A)method stack
C)call stack
B)location stack
D)store location
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
When appropriate, specialized ____ classes provide an elegant way for you to handle error situations.

A)Exception
C)Constructor
B)Error
D)Event
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
A(n) ____________________ block includes any number of statements that might cause exceptions.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
____ statements are program statements that can never execute under any circumstances.

A)Inaccessible code
C)Remote code
B)Unreachable code
D)Isolated code
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
A catch block has no return type and ____ be called directly.

A)cannot
C)can sometimes
B)can
D)can always
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
Each ____________________ block can catch only one type of exception.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
Object-oriented ____________________ provides a more elegant solution for handling error conditions than in previous procedural approaches.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
You can handle ____________________ either in a traditional manner or in an object-oriented manner.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Only the first ____________________ statement in a try block throws an exception.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
When you include a(n) ____________________ block, you are assured that the finally statements will execute before the method is abandoned, even if the method closes prematurely.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The ____________________ is where the computer stores the list of method locations to which the system must return.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
____________________ code statements are program statements that can never execute under any circumstances.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
When an exception is created and ____________________, the catch block that follows and contains an Exception argument executes.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
To create your own throwable exception, you usually ____________________ a built-in Exception class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
When you create your own exceptions by inheriting from a built-in Exception class, you gain access to methods contained in the ____________________ class, such as those that display a default message describing an exception and that display the stack trace.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
Programmers sometimes call a situation in which nothing goes wrong the ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
When a division by 0 happens during the execution of a method, the application that calls the method typically terminates, control returns to the operating system, and a(n) ____________________ is generated.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
In some languages, if an exception is thrown from one method and caught by another, you must write a(n) ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.