File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Checked Exception in static method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Checked Exception in static method" Watch "Checked Exception in static method" New topic

Checked Exception in static method

rahul deo

Joined: Jul 05, 2011
Posts: 10
Hi All

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
Rajdeep Biswas
Ranch Hand

Joined: Mar 26, 2012
Posts: 187

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 |
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Sure you can. It makes no difference whether the method is static or not, the same rules apply in both cases.
I agree. Here's the link:
subject: Checked Exception in static method
It's not a secret anymore!