Java uses an object-oriented approach to handle exceptions. It encapsulates each exception in a program into an object, which contains information about the exception.

Different types of exceptions are represented by different Java classes. The root class of all exceptions is java.lang.Throwable, and two subclasses are derived from Throwable: Error and Exception.

Error represents a serious problem that cannot be overcome and recovered by the application itself; the program can only hang, for example, system problems such as memory overflow and thread deadlocks.

Exception says the program will also be able to overcome the problem of and recovery, which is divided into system and ordinary anomaly, a system Exception is caused by the software itself defects, namely the problems caused by thoughtless software developers, software users unable to overcome and restore this kind of problem, but can also make the software system under this problem continues to run,

The (ArrayIndexOutOfBoundsException) arrays, for example, scripts, null pointer exception (NullPointerException), class cast exception (ClassCastException);

Java provides a different solution for system and normal exceptions, where the compiler enforces a try.. Catch processing or throws to the upper calling method with throws declaration, so common exceptions are also called checked exceptions,

System exceptions may or may not be handled, so the compiler does not force a try.. System exceptions are also called unchecked exceptions because catch is handled or declared with throws.

Small procedures: IT interview exercises