File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception Handling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception Handling" Watch "Exception Handling" New topic
Author

Exception Handling

chintan ramavat
Ranch Hand

Joined: Sep 15, 2006
Posts: 134
hello ranchers

I want to know " is it true method calling another has to declare exception or the called method takes care of it ? is that really "BUCKING" (not talking about handling but just declaring).i am aware of the STACK hierarchy(pardon for spell) but wanted make sure that would it compile or just give an error.

Thanks in advance

--Chintan
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
If method2() declares that it throws an exception, then method1() (calling method2()) must catch and handle the exception (or a superclass of the exception) or method1() must declare that it throws the exception (or a superclass of the exception). We say that method1() "passes the buck" or "ducks the exception" if it throws the exception that method2() throws.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
victor kamat
Ranch Hand

Joined: Jan 10, 2007
Posts: 247
Barry's comments are on target except that they only apply to checked exceptions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Exception Handling