Java exception classes are inherited from the Throwable class . Throwable mainly consists of two large categories. The error class and the exception class. The error class exception cannot be caught (it is a JVM exception or thread deadlock). Exception is divided into two types of non-check exceptions (runtimeexception) and check exceptions (non-runtime exceptions).
In Java, if the exception is not handled, the program terminates because of an exception. If a try-catch capture or throws is thrown, the program can be prevented from terminating because of an exception.
The exception is not handled in the. The program terminates after encountering an exception, and the last System.out.println () statement does not get output.
The exception is handled by using Try-catch in the. The program is not terminated because of an exception, but runs to the end. The SYSTEM.OUT.PRINTLN () statement after the catch also gets the output to validate.
Catching exceptions in Java