Java Custom Exception Project - Documentation
Project Name: Age Verification using Custom Exception
Description:
This project demonstrates the use of custom exceptions in Java. It simulates an age verification system
where users are allowed access only if they are 18 years or older.
Concepts Covered:
- Custom Exception Class (InvalidAgeException)
- Method with 'throws' keyword to declare exception possibility
- 'throw' keyword to manually raise an exception
- Exception handling using try-catch block
- Java naming conventions and exception design patterns
File Structure:
1. InvalidAgeException.java - Custom exception class extending Exception
2. Age.java - Contains check(int age) method that validates age
3. Test.java - Main class to execute and handle exception
Code Summary:
- If age < 18, throw new InvalidAgeException("Your age is less than 18.")
- If age >= 18, print "Access allowed"
- Exception is caught and handled in Test class using try-catch
Learning Outcome:
Java Custom Exception Project - Documentation
You will understand how Java exception propagation works, how to define and throw custom exceptions, and
how the calling code must handle or declare them. This lays the foundation for robust application
development.