The Chain of Responsibility pattern is a behavioral design pattern that passes a request along a chain of handler objects until one of them handles it. Each handler decides either to process the request or forward it to the next handler in the chain.
In an expense approval system, a request might first go to a team lead, then a manager, then a director, with each handler approving amounts up to their limit and forwarding anything higher up the chain.
public class ExpenseApprovalChain {
static abstract class Approver {
private Approver next;
private final String role;
private final int limit;
Approver(String role, int limit) { this.role = role; this.limit = limit; }
Approver then(Approver next) { this.next = next; return next; }
void approve(int amount) {
if (amount <= limit) {
System.out.println(role + " approved Rs " + amount);
} else if (next != null) {
next.approve(amount);
} else {
System.out.println("Rs " + amount + " rejected: above every limit");
}
}
}
static class TeamLead extends Approver { TeamLead() { super("Team lead", 10_000); } }
static class Manager extends Approver { Manager() { super("Manager", 50_000); } }
static class Director extends Approver { Director() { super("Director", 2_00_000); } }
public static void main(String[] args) {
Approver chain = new TeamLead();
chain.then(new Manager()).then(new Director());
chain.approve(4_000);
chain.approve(35_000);
chain.approve(1_50_000);
chain.approve(5_00_000);
}
}Team lead approved Rs 4000
Manager approved Rs 35000
Director approved Rs 150000
Rs 500000 rejected: above every limit
A concise interview answer is
Chain of Responsibility passes a request through a chain of handler objects, each deciding to process it or pass it along, which decouples the sender from knowing exactly who will handle the request and makes the handling logic easy to extend or reorder.
Last updated: 1 November 2026
Previous question: What are the potential downsides of using the Proxy pattern?
Next question: How would you implement the Chain of Responsibility pattern in Java?