Practice Exception Handling in Java
Handle errors gracefully using try-catch, throw, and custom exceptions.
Work through 24 exercises with starter code, expected output, test cases, and hints.
Exception Handling exercises
- Basic Try-Catch Java exercise — Handle a simple exception
- Multiple Catch Blocks Java exercise — Handle different exception types
- Using Finally Block Java exercise — Execute cleanup code with finally
- Throwing Exceptions Java exercise — Manually throw an exception
- Using Throws Clause Java exercise — Declare exceptions in method signature
- Try-With-Resources Java exercise — Automatic resource management
- Custom Exception Class Java exercise — Create and use custom exception
- Input Validation with Exceptions Java exercise — Validate user input using exceptions
- Exception Chaining Java exercise — Chain exceptions to preserve cause
- Retry with Exceptions Java exercise — Implement retry logic for failures
- Exception Propagation Java exercise — Understand exception propagation through call stack
- Age Range Validator Java exercise — Validate age is within acceptable range
- Password Validation Java exercise — Validate password against multiple rules
- Null Handling Java exercise — Handle NullPointerException gracefully
- Resource Cleanup Pattern Java exercise — Ensure resources are cleaned up
- Exception Logging Java exercise — Log exception details properly
- Retry Mechanism Java exercise — Implement automatic retry on failure
- Age Input Validation with Exceptions Java exercise — Validate user input using exceptions
- Aggregate Multiple Exceptions Java exercise — Collect and report multiple validation errors
- Graceful Degradation Java exercise — Provide fallback when operation fails
- Exception Chaining Java exercise — Chain exceptions to preserve root cause
- Custom AutoCloseable Java exercise — Create a resource that auto-closes
- Suppressed Exceptions Java exercise — Handle exceptions during close()
- Validation with Exceptions Java exercise — Validate input and throw appropriate exceptions
Browse the complete Java practice path · Open the online Java compiler