Exception Propagation in Java
Last Updated :
06 May, 2025
In Java, an exception is first thrown from the top of the stack, and if it is not caught, it drops down the call stack to the previous method. After a method throws an exception, the runtime system attempts to find something to handle it. The set of possible "somethings" to handle the exception is the ordered list of methods that had been called to get to the method where the error occurred. The list of methods is known as the call stack, and the method of searching is Exception Propagation.
The image below demonstrates the flow of method calls in a program

Exception Propagation in Unchecked Exceptions
When an exception happens, propagation is a process in which the exception is dropped from the top to the bottom of the stack. If not caught once, the exception again drops down to the previous method, and so on until it gets caught or until it reaches the very bottom of the call stack. This is called exception propagation, and this happens in case of Unchecked Exceptions.
In the example below, an exception occurs in the m() method, where it is not handled, so it is propagated to the previous n() method, where it is not handled, again it is propagated to p() method, where the exception is handled. Exceptions can be handled in any method in the call stack, either in the main() method, p() method, n() method, or m() method.
Note: By default, unchecked exceptions are forwarded in the calling chain (propagated).
Example:
JAVA
// Java program to illustrate
// unchecked exception propagation
// without using throws keyword
class Geeks {
void m()
{
int data = 50 / 0; // unchecked exception occurred
// exception propagated to n()
}
void n()
{
m();
// exception propagated to p()
}
void p()
{
try {
n(); // exception handled
}
catch (Exception e) {
System.out.println("Exception handled");
}
}
public static void main(String args[])
{
Geeks obj = new Geeks();
obj.p();
System.out.println("Normal flow...");
}
}
OutputException handled
Normal flow...
Exception Propagation in Checked Exceptions
Unlike Unchecked Exceptions, the propagation of exception does not happen in case of Checked Exception and its mandatory to use throw keyword here. Only unchecked exceptions are propagated. Checked exceptions throw compilation error.
In example below, If we omit the throws keyword from the m() and n() functions, the compiler will generate compile time error this is because checked exceptions cannot propagate without the explicit use of the throws keyword.
Note: By default, checked exceptions are not forwarded in calling chain (propagated). They must be declared in the method signature using the throws keyword.
Example:
JAVA
// Java program to illustrate exception propagation
// in checked exceptions and it can be propagated
// by throws keyword ONLY
import java.io.IOException;
class Geeks {
// 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[])
{
Geeks obj = new Geeks();
obj.p();
System.out.println("normal flow...");
}
}
OutputException handled
normal flow...
Unchecked Exceptions vs Checked Exceptions
The table below demonstrates the difference between unchecked and checked exception.
Property | Unchecked Exceptions | Checked Exceptions |
---|
Propagation | Propagate automatically through the call stack. | Do not propagate automatically. |
---|
Throws Keyword | Do not require the throws keyword | It requires a throw keyword |
---|
Compile-Time Check | Not checked at compile-time | Checked at compile-time, |
---|
Example | ArithmeticException, NullPointerException, IndexOutOfBoundsException. | IOException, SQLException |
---|
Similar Reads
Java Tutorial
Java is a high-level, object-oriented programming language used to build web apps, mobile applications, and enterprise software systems. It is known for its Write Once, Run Anywhere capability, which means code written in Java can run on any device that supports the Java Virtual Machine (JVM).Java s
10 min read
Java OOP(Object Oriented Programming) Concepts
Java Object-Oriented Programming (OOPs) is a fundamental concept in Java that every developer must understand. It allows developers to structure code using classes and objects, making it more modular, reusable, and scalable.The core idea of OOPs is to bind data and the functions that operate on it,
13 min read
Java Interview Questions and Answers
Java is one of the most popular programming languages in the world, known for its versatility, portability, and wide range of applications. Java is the most used language in top companies such as Uber, Airbnb, Google, Netflix, Instagram, Spotify, Amazon, and many more because of its features and per
15+ min read
Arrays in Java
Arrays in Java are one of the most fundamental data structures that allow us to store multiple values of the same type in a single variable. They are useful for storing and managing collections of data. Arrays in Java are objects, which makes them work differently from arrays in C/C++ in terms of me
15+ min read
Inheritance in Java
Java Inheritance is a fundamental concept in OOP(Object-Oriented Programming). It is the mechanism in Java by which one class is allowed to inherit the features(fields and methods) of another class. In Java, Inheritance means creating new classes based on existing ones. A class that inherits from an
13 min read
Collections in Java
Any group of individual objects that are represented as a single unit is known as a Java Collection of Objects. In Java, a separate framework named the "Collection Framework" has been defined in JDK 1.2 which holds all the Java Collection Classes and Interface in it. In Java, the Collection interfac
15+ min read
Java Exception Handling
Exception handling in Java allows developers to manage runtime errors effectively by using mechanisms like try-catch block, finally block, throwing Exceptions, Custom Exception handling, etc. An Exception is an unwanted or unexpected event that occurs during the execution of a program, i.e., at runt
10 min read
Java Interface
An Interface in Java programming language is defined as an abstract type used to specify the behaviour of a class. An interface in Java is a blueprint of a behaviour. A Java interface contains static constants and abstract methods. Key Properties of Interface:The interface in Java is a mechanism to
12 min read
Java Programs - Java Programming Examples
In this article, we will learn and prepare for Interviews using Java Programming Examples. From basic Java programs like the Fibonacci series, Prime numbers, Factorial numbers, and Palindrome numbers to advanced Java programs.Java is one of the most popular programming languages today because of its
8 min read
Polymorphism in Java
Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read