by Dinesh Thakur

A java exception can be thrown only in the following three scenarios:


(1) An abnormal execution condition was synchronously detected by the Java virtual machine.


- When evaluation of an expression violates the normal semantics (Example: an integer divide by zero)
- An error occurs in loading or linking part of the program
- When limitation on a resource is exceeded (Example: using too much memory)


(2) A throw statement was executed.


(3) An asynchronous exception occurred.

- The stop method (deprecated) of class Thread was invoked
- An internal error has occurred in the java virtual machine