It's not a secret anymore!*
The moose likes Java in General and the fly likes Checked exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Checked exception" Watch "Checked exception" New topic

Checked exception

sparsh khandelwal
Ranch Hand

Joined: Dec 20, 2010
Posts: 70
what is the meaning of the line that checked exception can not forward in calling chain

[Thumbnail for ScreenShot002.jpg]

Junilu Lacar

Joined: Feb 26, 2001
Posts: 4442

Please QuoteYourSources (←click) ... I have no idea what that's supposed to mean either.

Junilu - [How to Ask Questions] [How to Answer Questions]
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11150

screenshots like that are VERY hard for some of us to read. Can you past the test into a post instead?

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
sparsh khandelwal
Ranch Hand

Joined: Dec 20, 2010
Posts: 70
here is the linklink
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074

With checked exceptions, you must either catch them, or explicitly specify that the method inside which the exception might be thrown, passes it on the the calling method, by using a throws clause in the method declaration.

For example, if you have a method that throws a checked exception such as IOException:

This will not compile, because the method does not catch the exception, and it also doesn't have a throws clause. You have to fix it, for example like this:

See The Catch or Specify Requirement.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37890
I am getting déjà vu. Is that the same website we told you to avoid recently?
Jeff Verdegan

Joined: Jan 03, 2004
Posts: 6109

Campbell Ritchie wrote:I am getting déjà vu. Is that the same website we told you to avoid recently?

Wow. Awful indeed. His two main points on that page, "By rule, unchecked/checked exceptions are/are not propagated," are nonsense. The rules for propagation are exactly the same for every exception: If it's not caught, it bubbles up to the next nearest enclosing try block. That's the runtime behavior of every exception. The compile-time catch-or-declare rule for checked exceptions is a separate issue from that.
I agree. Here's the link:
subject: Checked exception
Similar Threads
method overriding
Exception Doubt
Checked application exception