Home / Questions / What is the role of (i) throws keyword ? (ii) throw keyword ?
Explanatory Question

What is the role of (i) throws keyword ? (ii) throw keyword ?

👁 30 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Keyword Purpose
throw Used to manually throw an exception. Example: throw new IOException("Error!");
throws Declares that a method might throw an exception. Example: void readFile() throws IOException