A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Checked Exception in static method
Joined: Jul 05, 2011
Dec 05, 2012 22:25:50
Can we throw a checked exception in a static method? I am confused , because till now i know that We can throws only a runtime exception. So if we can throw a checked exception then why and how? Thanks in advance
Joined: Mar 26, 2012
Dec 05, 2012 22:40:05
I'd recommend you to try to do so. Compiler will let you know, else you can see the behavior during execution. Then you can post here what you found!
The biggest gamble will be to ask a question whose answer you know in that it will challenge your theory | www.TechAspire.blogspot.in
Joined: Oct 14, 2005
Dec 05, 2012 22:59:48
Sure you can. It makes no difference whether the method is static or not, the same rules apply in both cases.
It is sorta covered in the
JavaRanch Style Guide
subject: Checked Exception in static method
Runtime Excepiton and Checked Exception
overriding and overloading
exception as a argument
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014