Exception Handling Flashcards

1
Q

What are compile time errors?

A

Errors that occur when you violate the rules of writing syntax are known as Compile-Time errors.

Most of the compile-time errors are due to typing mistakes.
The most common problems are:
 Missing semicolons
 Missing (or mismatch of) brackets in classes and
methods
 Misspelling of identifiers and keywords Missing
double quotes in strings
 Use of undeclared variables
 Incompatible types in assignments, initializations.
 Bad references to objects
 Use of = in place of = = operator

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are runtime errors?

A

A runtime error in a program is an error that occurs while the program is running after being successfully compiled.
Runtime errors are commonly called referred to as “bugs” and are often found during the debugging process before the software is released.

The most common run-time errors are:
 Dividing an integer by zero
 Accessing an element that is out of the bounds of an array
 Trying to store a value into an array of an incompatible class or type
 Trying to cast an instance of a class to one of its subclasses
 Passing a parameter that is not in a valid range or value for a
method
 Trying to illegally change the state of a thread
 Attempting to use a negative size for an array
 Using a null object reference as a legitimate object reference to
access a method or a variable
 Converting an invalid string to a number
 Accessing a character that is out of bounds of a string

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What Is an Exception?

A
An exception is an abnormal event that arises during
the execution (run time) of the program and disrupts
the normal flow of the program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Java Error Class?

A
 An Error is a subclass of Throwable that indicates serious
problems.

 Errors represent critical errors, once occurs the system is not
expected to recover from (irrecoverable).

 Errors can be generated from mistake in program logic or
design.

 Most applications should not try to handle it.
e.g. OutOfMemoryError, VirtualMachineError, AssertionError

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Java Exception Class?

A
This class represents the exceptional conditions that user
must handle or catch.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are Checked Exceptions?

A

 Checked Exception in Java is all those Exception which requires being catches and handled during compile time.

 The classes that extend Throwable class except RuntimeException and Error are known as checked exceptions

e.g.IOException, SQLException etc. Checked

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are Unchecked Exceptions?

A

 Unchecked exceptions are usually caused by incorrect program code or logic such as invalid parameters passed to a method.

 The classes that extend RuntimeException are known as unchecked exceptions.

 Unchecked exceptions are checked at runtime.

e.g. ArithmeticException, NullPointerException, ArrayIndexOutOfBoundsException

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Two ways to handle Exceptions?

A

 Throw out and ignore

When an Exception occurs inside a code of the program simply
throw it out and ignore that an Exception occurs declare the
methods as throws Exception.

 Catch and handle

If a code segment is generating an Exception place it inside a
try block. Then mention the way to handle the Exception
inside a catch block use try-catch block

How well did you know this?
1
Not at all
2
3
4
5
Perfectly