When throws keyword is used?
Who knows best answer for that question?

Recommended Answers

All 2 Replies

there is no "best answer" there's just the answer.
the throws keyword is used in the signature of a/the method, to indicate that it might throw a certain type of Exception, forcing all the methods that call this method, to either implement some exception handling, or to throw the exception themselves.

here are some links for you to take a look at:
http://docs.oracle.com/javase/tutorial/essential/exceptions/
http://docs.oracle.com/javase/tutorial/essential/exceptions/throwing.html
http://docs.oracle.com/javase/tutorial/essential/exceptions/declaring.html

Any method capable of causing exceptions must list all the exceptions possible during its execution, so that anyone calling that method gets a prior knowledge about which exceptions to handle. A method can do so by using the <b>throws</b> keyword

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.