✏️ Explanatory Question

What type of exceptions must be explicitly declared in a throws clause of a method?

👁 37 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

All exceptions except those of type RuntimeException and Error must be explicitly declared in a method’s throws clause.
In other words, checked exceptions must be declared, while unchecked exceptions do not require declaration.

Example:


public void readFile() throws IOException {
    // Code that may throw IOException
}