An exception, in programming, is an unplanned event, such as invalid input or a loss of connectivity, that occurs while a program is executing and disrupts the flow of its instructions. Exception is a short way of saying exceptional event.
In Java, exceptions exist as a class, java.lang.Exception, with two main subclasses, IOException and RuntimeException. Checked exceptions occur when the program is compiled; for the most part, the program should be able to recover from these. These can be things like FileNotFoundException, for example, or InvalidInputException. Exception handling code can be written to deal with the issue, so that the program can continue.
Unchecked exceptions are events that aren’t planned for, so they aren’t checked at compile time – they happen when the program executes and typically can’t be handled. An unchecked exception that cannot be handled by the program is known as a fatal exception because it forces the operating system to close the program and possibly shut down the entire system. An error is a type of unchecked exception, although there are others.