✏️ Explanatory Question
Solution:
| Keyword | Purpose | Used In | Example |
|---|---|---|---|
| throw | Used to explicitly throw an exception from a method or block of code. | Inside a method or block. | throw new IOException("File not found"); |
| throws | Used to declare that a method may throw certain exceptions. | In the method declaration. | void readFile() throws IOException |
Explanation:
throw is used when you want to manually raise an exception.
throws is used when you want to inform the caller that this method might throw an exception that it must handle.