The throw statement in Java is used to explicitly raise an exception within a function, and it applies to both checked and unchecked exceptions within the method. It allows for the controlled triggering of exceptions during program execution, making it possible to properly handle uncommon scenarios.
The throws keyword in Java is used to declare an exception in a program, mostly for Checked Exceptions, allowing methods to declare numerous exceptions that may be thrown during execution. This provides a clear indicator of potential uncommon occurrences and allows for appropriate management in calling code.
The term "custom exception" refers to the creation of one's exception to customize an exception to meet specific demands. The custom exceptions derive from the Exception class.
To build a custom exception, you have to create a class that inherits from the Exception class.