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 a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com