This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Exception handling questions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Exception handling questions" Watch "Exception handling questions" New topic

Exception handling questions

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Sorry new to exception handling, currently doing URLyBird project, and have 2 questiions.
If someone has a method in an interface like following say,
"public String[] read(int recNo) throws RecordNotFoundException"
If an error is declared in method like this, does that mean this method does not catch the exception but rather propogates it upwards to whoever is calling it?
For the project, if 1 creates their own errors do they have choice of either extending the exception or runtimeException class?
Roel De Nijs

Joined: Jul 19, 2004
Posts: 7233

Hi Mark,

1) such a method signature means: method can throw a RecordNotFoundException (and so the method itself is not handling it, the code where this method is called, should handle it or propagate it too).

2) extending Exception or extending RuntimeException is your own decision. In my assignment RNFE was a checked exception.

Kind regards,

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Thanks Roel. They were the responses I was hoping for.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Exception handling questions
It's not a secret anymore!