For example in number divide by zero how try block identify that at what statement it has to throw the exception. does it check the denominator value implicitly and it does than how it knows
1 Answer
Exceptions don't work that way.
The try{} catch {} blocks doesn't know anything, as it is not the one throwing an exception, it is just there on how to handle an exception thrown by code inside the try block.
In your case, ArithmeticException is thrown at runtime by the VM when the denominator is 0, after that the stacktrace is populated as in case of any exception.
ArithmeticException is thrown when an exceptional arithmetic condition has occurred. For example, an integer "divide by zero" throws an instance of this class. ArithmeticException objects may be constructed by the virtual machine as if suppression were disabled and/or the stack trace was not writable.
try{} catch{}block ??