Exceptions are Java s way of dealing with error or exceptional conditions. An example is divide by zero. An exceptional condition is caused when something out of the ordinary needs to be handled. If unusual seismic activity is detected in California, you want to notify the authorities immediately. While explicit tests can be done indeed, this is what we are used to it can make for harder code to read.
Exceptions provide a uniform way of dealing with such conditions.
Exceptions are propagated to the calling method Exceptions are then caught by an encompassing clause in the calling method. All exceptions in Java are subclassed from the Exception base class or one of its subclasses. Exceptions have two constructors, one with no parameters and one with a string. Raising an exception Exceptions are raised by a throw statement, which you may or may not see. The throw might be a result of explicitly calling an exception, or because it was thrown by the JVM or a class library you are using.