Java Exception propagation
If an exception occurs in the protected code, the exception is thrown from the top of the stack. If not caught then it drops down to the previous method. This continues until the exception either is caught or until they reach the very bottom of the call stack. This process is known as Exception propagation.
Example
class ExceptionPro{ void a(){ int data=1/0; } void b(){ a(); } void c(){ try{ b(); }catch(ArithmeticException e){ System.out.println("Exception handled"); } } } public class ExceptionPropagation{ public static void main(String args[]){ ExceptionPro ep=new ExceptionPro(); ep.c(); System.out.println("Code running normal flow"); } }
Quickly Find What You Are Looking For
Onlinetpoint is optimized for basic learning, practice and more. Examples are well checked and working examples available on this website but we can't give assurity for 100% correctness of all the content. This site under copyright content belongs to Onlinetpoint. You agree to have read and accepted our terms of use, cookie and privacy policy.