Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Exception Handling - Lecture Notes | CSC 3405, Study notes of Computer Science

Material Type: Notes; Professor: Wei; Class: Intro Computer Programming; Subject: Computer Science; University: Saint Joseph's University; Term: Unknown 1989;

Typology: Study notes

Pre 2010

Uploaded on 08/18/2009

koofers-user-yws
koofers-user-yws 🇺🇸

10 documents

1 / 6

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Chapter 9
Exception Handling
 Multiple ChoiceMultiple Choice
1) Try blocks contain code that could possibly:
(a) handle an exception
(b) throw an exception
(c) catch an exception
(d) display an exception
2) The Exception class belongs to the package:
(a) java.io
(b) java.util
(c) java.lang
(d) java.except
3) The execution of a throw statement is referred to as:
(a) catching a block
(b) trying a block
(c) handling an exception
(d) throwing an exception
4) The catch block has ________ parameters.
(a) zero
(b) one
1
pf3
pf4
pf5

Partial preview of the text

Download Exception Handling - Lecture Notes | CSC 3405 and more Study notes Computer Science in PDF only on Docsity!

Chapter 9

Exception Handling

 Multiple Choice

  1. Try blocks contain code that could possibly: (a) handle an exception (b) throw an exception (c) catch an exception (d) display an exception
  2. The Exception class belongs to the package: (a) java.io (b) java.util (c) java.lang (d) java.except
  3. The execution of a throw statement is referred to as: (a) catching a block (b) trying a block (c) handling an exception (d) throwing an exception
  4. The catch block has ________ parameters. (a) zero (b) one 1

(c) two (d) three

  1. A ___________ block should immediately follow a try block. (a) try (b) catch (c) fail (d) final
  2. When defining your own exception class, you extend an existing exception class. This is an example of: (a) polymorphism (b) encapsulation (c) inheritance (d) all of the above
  3. If a method does not catch an exception, then it must at least warn programmers that any invocation of the method might possibly throw an exception. This warning is called a/an: (a) Exception handler (b) Throws clause (c) Try block (d) Catch block
  4. If a method throws an exception, and the exception is not caught inside the method, then the method invocation: (a) terminates (b) transfers control to the catch block (c) transfers control to the exception handler
  1. All exceptions are descendants of the class: (a) Throwable (b) Catchable (c) Tryable (d) Blockable
  2. Exception handling is an example of a programming methodology known as: (a) structured programming (b) object oriented programming (c) goto programming (d) event-driven programming
  3. A _________ block executes regardless of whether an exception occurs. (a) final (b) finally (c) catch (d) none of the above
  4. When using the Scanner class one should account for a/an: (a) NumberFormatException (b) InputMismatchException (c) ArrayIndexOutOfBoundsException (d) PowerFailureException
  5. ArrayIndexOutOfBoundsException is a descendent of the class RuntimeException. This means:

(a) the exception must be caught (b) a finally block must be included (c) the exception does not have to be explicitly caught (d) none of the above

  1. An exception is caught in a _________ block. (a) try (b) catch (c) finally (d) all of the above

 True/False

  1. The throw operator causes a change in the flow of control.
  2. The basic way of handling exceptions in Java consists of the try-catch-throw trio.
  3. When an exception is thrown, the code in the surrounding try block continues executing and then the catch block begins execution.
  4. Every exception class is an ancestor of the class Exception.
  5. The two most important things about an exception object are its type and the message that it carries in an instance variable of type String.
  6. A program can catch multiple exceptions.
  7. The compiler does not complain when the catch or declare rule is ignored.
  8. Exceptions that must follow the Catch or Declare Rule are often called unchecked exceptions.
  9. In event-driven programming, sending an event is called firing the event.
  10. You can not place a try block and its following catch blocks inside a larger try block or inside a larger catch block.
  11. The finally block contains code to be executed whether or not an exception is thrown in a try block.