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: 2341
posted
0
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
posted
0
Second part is same as your previous thread throw where i gave its explanation.
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.