Вы находитесь на странице: 1из 2

Exceptions are runtime errors caused due to logical mistakes occurred during program execution.

If exceptions are raised in the program, that program execution is terminated abnormally. It means statements placed after exception causing statement are not executed but the statements placed before that exception causing statement are executed by JVM. Exceptions are raised due to wrong input. Ex: creating an array with negative number, here ve number is the wrong input, so JVM terminates program execution by throwing an Exception of type java.lang.NegativeArraySizeException. The throwable class is the super class of all exceptions in the java language. Only objects those are instances of this class are thrown by the JVM or can be thrown by the java Developer using throw statement. For all types of exceptions java.lang.Throwable is super class. It has two main subclasses Error Exception Error type exceptions are raised or thrown due to the problem occurred in side JVM, If there is no memory in JSA to create new Stack frame to execute method, then JVM process is killed by throwing error type exception java.lang.StackOverFlowError. If there is no memory in HA to create new object, then JVM process is killed by throwing error type exception java.lang.OutofMemoryError. Exception type exceptions are raised or thrown, due to the problem occurred in java program logic execution, like If we divide an integer number with zero, then JVM terminates program execution by throwing exception type exception java.lang.ArithmeticException We cannot catch error type exceptions, because if error type exception is raised JVM process will be terminated. We can catch exception type exceptions, because JVM process will not be terminated. An exception is an event, which occurs during the execution of a program that disrupts the normal execution flow of the programs instructions.

Вам также может понравиться