• Dear Guest, Please do NOT forget to join our JAVA JOBS (ONLY) FACEBOOK GROUP to be aware of latest JAVA openings, and you may also post any JAVA related queries/jobs.

Explain about the 'throws' keyword ?

Someone told me, that using 'throws' keyword along with main() is not recommended in real time?

Is it correct approach?

why ?
If the method is unable to handle the exception then we use throws keyword along with the method.
Syntax: datatype method-name(parameters list) throws exception1,exception2...
Be careful when you use the throws keyword. It means that the user of your methods will need to worry about it. If your main() method throws exceptions it could mean that its caller may have problems with it and your program can crash. Remember that if you throw an exception then you must catch it as well.