Hi Abhineet,
I tried your code which works fine without any exception. Then i changed division statement in static block to c=b/a. This time it gave following output -
static block started
java.lang.ExceptionInInitializerError
Caused by: java.lang.ArithmeticException: / by zero
at
test.<clinit>(test.java:9)
Exception in
thread "main"
Static block is executed before execution of Main method starts. Any exception E if not caught in static block then If the class of E is not Error or one of its subclasses, then a new instance of the class ExceptionInInitializerError is created, with E as the argument, and used. But if a new instance of ExceptionInInitializerError cannot be created because an OutOfMemoryError occurs, then instead an OutOfMemoryError object in place of E is used.
Regards