public static void main(String args[])
{
   int a, b;
   try
   {
      a = 0;
      b = 42 / a;
      System.out.println("This will not be printed.");
   }  
?
   catch (ArithmeticException e)
   {
      System.out.println("Division by zero.");
   }
   System.out.println("After catch statement.");
}
?
The program above includes a try block and a catch clause that processes the ArithmeticException generated by the division-by-zero error. Explain how the try and catch blocks operate, and what the output will be following program execution.

What will be an ideal response?


The call to the println() statement inside the try block is never executed. Once an exception is thrown, program control transfers out of the try block into the catch block. The catch is not "called," so execution never "returns" to the try block from a catch. Thus, the line "This will not be printed." is not displayed. Once the catch statement has executed, program control continues with the next line in the program following the entire try/catch pair.

Computer Science & Information Technology

You might also like to view...

The ____ are an explicit statement of the expected outcome of each information security activity.

A. controls B. control objectives C. control structures D. control blocks

Computer Science & Information Technology

By selecting the ________ option, you can make sure that data entered into a related table first exists in the primary table

A) sort B) form wizard C) referential integrity D) query wizard

Computer Science & Information Technology

A(n) ________ chart is useful for illustrating comparisons among related categories

Fill in the blank(s) with correct word

Computer Science & Information Technology

Which of the following must use NSA approved algorithms to be considered a Type 1 encryption device?

A. SIEM B. INE C. HSM D. HIPS

Computer Science & Information Technology