Chapter 11
What is an unchecked exception?
An exception that occurs at the time of execution.(rutimeexception) Do not require a throws clause.
When using the printwriter class you must end the app with what?
System.close()
When we have an error out?
System.err
When we read information in what type of stream is that?
System.in
When we put information out?
System.out
What is the purpose of a try-catch block?
To process an exception where it occurs, the statement that throws (or raises) the exception is executed within a try block
A program can manage multiple I/O streams simultaneously
True
The statement in the finally block is always executed T or F?
True
An attempt to divide by zero will cause what exception to be thrown?
True—Division by zero is invalid, so an exception is thrown
If a program does not handle an exception, a message related to the exception will be produced.
True—If the exception is not handled, the program will terminate and display a message
A NoSuchMethodException is a checked exception
True—It does not inherit from RunTimeException
An ArithmeticException is an exception
True—It inherits from RunTimeException which inherits from Exception
An ArithmeticException is throwable
True—It inherits from Throwable through RunTimeException and Exception
A call stack trace shows the sequence of method calls that led to the code where an exception occurred.
True—That is the purpose of the call stack trace.
If a program does not handle a raise exception, the exception is ignored and nothing happens.
False—An exception must be either handled or thrown
An exception and an error are the same thing.
False—Exceptions and errors are related but are not always the same thing
An ArithmeticException is a checked exception
False—It inherits from RunTimeException so it is unchecked
What is a checked exception?
an exception that must be either (1) caught and handled or (2) listed in the throws clause of any method that may throw or propagate it. This establishes a set of exceptions that must be formally acknowledged in the program one way or another.
What is an exception?
an object that describes an unusual or erroneous situation
What is an error?
an unrecoverable situation and should not be caught.
How are exceptions handled?
are thrown (or raised) by a program during execution; they may be caught and handled, or they may be ignored (as we've been doing)
How might a thrown exception be handled?
can be handled in one of three ways: it can be ignored, which will cause a program to terminate; it can be handled where it occurs using a try statement; or it can be caught and handled higher in the method calling hierarchy.
IO classes assume that data consists of what?
characters, binary, raw bytes.
IOException is what kind of exception?
checked exception
An exception can be what?
checked or unchecked
What does the java.io package contain?
classes that allow us to define various streams with particular characteristics.
What is a catch clause?
defines the code that will handle a particular type of exception.
How do you initialize a checked exception?
either must be caught by a method or must be listed in the throws clause of any method that may throw or propagate it.
A program can be seperated into normal execution flow and?
exception execution flow
What is the difference between an error and an exception?
exception is an object that defines an unusual or erroneous situation. An error is similar, except that an error generally represents an unrecoverable situation and should not be caught.
Where is a throws clause appened?
header of the method
What is exception propagation?
if exception cant be handles where it occurs it goes up until it is caught and handle or it reaches the main method.
A program can deal with an exception in one of three ways?
ignore it, handle it where it occurs, handle it in another place in the program.
What is a stream?
is a sequential series of bytes that serves as a source of input or a destination for output.
What is a finally clause?
is executed no matter how the try block is exited. If no exception is thrown
What happens if an exception is not caught?
it begins to propagate up through the methods that were called to get to the point where it was generated. The exception can be caught and handled at any point during that propagation.
What do we use to read from a file?
java.io.File, java.util.Scanner
What do we use to write to a file?
java.io.PrintWriter
What must follow a try block?
one or more catch blocks or a finally
What happens when an exception occurs?
processing continues at the first catch block that matches the exception type.
What happens when an exception is ignored?
runtime error
What does the call stack trace do?
shows the method call trail that led to the attempted execution of the offending line of code.
What are the standard I/O streams?
system.in,system.err,system.out