Exception Handling Flashcards
what is an exception?
an error which occurs during a normal flow of a program
why is exceptions bad?
they cause disrupted and abnormally terminates program
exception handling helps to … (4 points)
1- try to recover
2- retry operation
3- display meaningful error
4- terminating the whole program but in a better way
we use what operations for exception handling
try-catch or try-catch-finally
if i divide by zero what type of exception occurs
ArithmeticException
if an array index is more than the size or equals to -1 which exception is used
ArrayIndexOutOfBoundsException
types of exceptions
checked and unchecked
checked exceptions are handled at (compile, runtime)?
compile time
how to fix checked exceptions
try-catch, and extend a throwable class either directly or indirectly
examples of checked exceptions
FileNotFoundException and PrinterException
unchecked exceptions occurs where?
outside the program
most of the time unchecked exception can be expected or recovered (t or f)
false, most of the time it cannot be expected or recovered from
how to fix unchecked exceptions?
must extend RuntimeException class directly or indirectly
examples for unchecked exceptions?
NullPointerException , ClassCastException
printwriter pckage is
java.io