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 which of the statements are true... 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 "which of the statements are true..." Watch "which of the statements are true..." New topic
Author

which of the statements are true...

Supriya Nimakuri
Ranch Hand

Joined: May 23, 2006
Posts: 83
A. catch(X x) can catch subclasses of X.
B. Any statement that can throw an Exception must be enclosed in a try block.

I guess Statement B is true..if not why..

Regards
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
No, RuntimeException, Error, and their subclasses are unchecked exceptions. Code that may throw them is not required to be in a try block nor is the exception required to be listed in the throws clause of the method containing the code.
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Second part is same as your previous thread throw where i gave its explanation.


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Karol Kisielewski
Greenhorn

Joined: Jun 28, 2006
Posts: 8
Originally posted by Supriya Nimakuri:
A. catch(X x) can catch subclasses of X.
B. Any statement that can throw an Exception must be enclosed in a try block.

I guess Statement B is true..if not why..

Regards


B. No, because the method inside which the statement exists can propagate the exception up via method's throws clause without enclosing the statement in try-catch block.
 
GeeCON Prague 2014
 
subject: which of the statements are true...