aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question about  handle and Declare, and PageNo 104 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question about  handle and Declare, and PageNo 104" Watch "Question about  handle and Declare, and PageNo 104" New topic
Author

Question about handle and Declare, and PageNo 104

sachin verma
Ranch Hand

Joined: Mar 25, 2008
Posts: 177
I know only one situation where we have to follow handle and Declare rule for Exceptions.that is when we are rethrowing the same exception (checked) from the catch block as given on page no 365 K&B book.
My question is

Is there any other situation where we have to follow the same rule of "handle and Declare" ?
[ May 08, 2008: Message edited by: sachin verma ]

SCJP || SCWCD

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38796
    
  23
Anywhere that you might throw a checked Exception falls into the handle or declare rule.

If you have
  • throw new Throwable();
  • throw new Exception();
  • throw new IOException();
  • throw new AnyOtherNonRuntimeException();
  • or, any call to a method which declares a checked Exception,
  • you are in the realms of handle or declare.
    Jart Bo
    Ranch Hand

    Joined: Oct 22, 2007
    Posts: 144
    Yes, if you are throwing an exception in the catch block.. I believe that is the only scenario where you will need to handle and declare the exception.


    SCJP, SCWCD
    sachin verma
    Ranch Hand

    Joined: Mar 25, 2008
    Posts: 177
    Modified Version of Exam watch on page no 104

    Is this not another case of Handle and Declare?

    If not please explain why?


    [ May 08, 2008: Message edited by: sachin verma ]
    Dumitru Postoronca
    Ranch Hand

    Joined: May 06, 2008
    Posts: 46
    I believe it's "handle or declare"
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Question about handle and Declare, and PageNo 104