Exam 12: Exception Handling

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Match each term with the correct statement below. -Object-oriented techniques to manage errors

Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
Verified

C

____ exceptions are the type that programmers should anticipate and from which programs should be able to recover.

Free
(Multiple Choice)
4.9/5
(39)
Correct Answer:
Verified

C

Match each term with the correct statement below. -Constructs a new exception with the specified detail message

Free
(Multiple Choice)
4.9/5
(44)
Correct Answer:
Verified

B

What things might a programmer do to cause a potential exception in a program?

(Essay)
4.8/5
(46)

Some programmers refer to a catch block as a catch ____.

(Multiple Choice)
4.8/5
(34)

When you have actions you must perform at the end of a try…catch sequence, you can use a ____ block.

(Multiple Choice)
4.9/5
(40)

import java.util.*; public class DivisionMistakeCaught3 { public static void main(String[] args) { Scanner input = new Scanner(System.in); int numerator, denominator, result; try { System.out.print("Enter numerator >> "); numerator = input.nextInt(); System.out.print("Enter denominator >> "); denominator = input.nextInt(); result = numerator / denominator; System.out.println(numerator + " / " + denominator + " = " + result); } catch(ArithmeticException mistake) { System.out.println(mistake.getMessage()); } catch(InputMismatchException mistake) { System.out.println("Wrong data type"); } } } Using the above code, describe what will happen if a user enters two usable integers. What will happen if a user enters an invalid noninteger value? What will happen if the user enters 0 for the denominator?

(Essay)
4.8/5
(35)

Which method constructor constructs a new exception with the specified detail message and cause?

(Multiple Choice)
4.7/5
(36)

____ represents the degree to which a system is resilient to stress, maintaining correct functioning.

(Multiple Choice)
4.7/5
(36)

If you create an object using Java's BigDecimal class, and then perform a division that results in a non-terminating decimal division such as 1/3, but specify that an exact result is needed, a(n) ____________________ is thrown.

(Short Answer)
4.8/5
(43)

The parent class of Error is ____.

(Multiple Choice)
4.7/5
(29)

public class exceptions { public static void main(String Args[]) { int[] array = new int[3]; try { for(int a=0;a<4;++a) { array[a] = a; } System.out.println(array); } catch(ArrayIndexOutOfBoundsException e) { System.out.println("Out of bounds"); } } } In the above code, the line System.out.println(array); gets skipped when an exception occurs. Write a finally block that will execute, and will execute a System.out.println(array); if there is an exception.

(Essay)
4.8/5
(37)

A(n) ____ clause is used in the method header so that applications that use your methods are notified of the potential for an exception.

(Multiple Choice)
4.7/5
(35)

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.

(Essay)
4.8/5
(38)

What advantage to programmers does the technique of cycling through the methods in the stack offer? Why?

(Essay)
4.9/5
(37)

Any ____________________ block might throw an Exception for which you did not provide a catch block.

(Short Answer)
4.8/5
(40)

Match each term with the correct statement below. -A process that is crucial to an organization

(Multiple Choice)
4.8/5
(41)

The ____ class represents more serious errors from which your program usually cannot recover.

(Multiple Choice)
4.8/5
(39)

Match each term with the correct statement below. -Constructs a new exception with the specified cause and a detail message of cause.toString()

(Multiple Choice)
4.9/5
(27)

The keyword catch followed by an Exception type in the method header is used when a method throws an exception that it will not catch but that will be caught by a different method.

(True/False)
4.9/5
(39)
Showing 1 - 20 of 65
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)