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

Single Choice
Views 36

Answer:

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
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.