In Exception Propagation, uncaught exceptions are propagated in the
call stack until stack becomes empty. This propagation is called
Exception Propagation.
Let say an exception propagates from one method to another method.
A() calls B(), which calls C(), which calls D(). And if D() throws
an exception, the exception will propagate from D to C to B to A,
unless one of the methods catches the exception.
xxxxxxxxxx
class Simple {
// exception propagated to n()
void m() throws IOException
{
// checked exception occurred
throw new IOException("device error");
}
// exception propagated to p()
void n() throws IOException
{
m();
}
void p()
{
try {
// exception handled
n();
}
catch (Exception e) {
System.out.println("exception handled");
}
}
public static void main(String args[])
{
Simple obj = new Simple();
obj.p();
System.out.println("normal flow...");
}
}