List various exceptional conditions that have occurred throughout this text. List as many additional exceptional conditions as you can. For each of these exceptions, describe briefly how a program typically would handle the exception, using the exception-handling techniques discussed in this chapter. Some typical exceptions are division by zero, arithmetic overflow, array subscript out of bounds, exhaustion of the free store, etc.

What will be an ideal response?


A few examples are: Division by zero—check the denominator to see if it is equal to zero, and throw an exception before the division occurs. Array subscript out of bounds—catch the exception, print an error message telling the user what index was trying to be referenced, and exit the program in a controlled manner. Exhaustion of
the free store—catch the exception, and either deallocate enough other objects so that you can allocate memory for the new object or delete all objects and terminate the program. Bad cast—catch the exception and either cast the operand to the proper type, if that can be determined, or print an error message indicating what the bad cast was, and exit the program.

Computer Science & Information Technology

You might also like to view...

In the following code, what is the output for list2?

``` public class Test { public static void main(String[] args) { int[] list1 = {1, 2, 3}; int[] list2 = {1, 2, 3}; list2 = list1; list1[0] = 0; list1[1] = 1; list2[2] = 2; for (int i = 0; i < list2.length; i++) System.out.print(list2[i] + " "); } } ``` a. 1 2 3 b. 1 1 1 c. 0 1 2 d. 0 1 3

Computer Science & Information Technology

The ________ option shown after clicking the Character Spacing button moves selected text characters more closely together

A) Loose B) Tight C) Normal D) Condensed

Computer Science & Information Technology

Describe the inter-mail server vulnerability.

What will be an ideal response?

Computer Science & Information Technology

When you set up an Internet Information Services (IIS) Web server, how can you protect your network against an overwhelming number of requests as a result of a particularly popular page or a malicious attack?

What will be an ideal response?

Computer Science & Information Technology