C
Chuck Bowling
In studying for the 70-316 I ran across the question below. I'm a little
confused by the 'correct' answer. Why is it necessary to wrap the Validate
method in a try/catch block? Doesn't the Exception that's thrown in the call
to Validate propagate up the call stack to the parent form without any need
to rethrow it?
==========================================
Create a component named Request. This component includes a method named
AcceptRequest that attempts to process new user requests for services. The
AcceptRequest component calls a private function named Validate.
You must ensure that any exceptions encountered by Validate are bubbled up
to the parent form of Request. The parent form will then be responsible for
handling the exceptions. You want to accomplish this while writing the
minimum amount of code.
What should you do?
Use the following code segment in AcceptRequest:
A) this.Validate();
B) try {
this.Validate();
}
catch(Exception ex) {
throw ex;
}
Answer: B
==========================================
confused by the 'correct' answer. Why is it necessary to wrap the Validate
method in a try/catch block? Doesn't the Exception that's thrown in the call
to Validate propagate up the call stack to the parent form without any need
to rethrow it?
==========================================
Create a component named Request. This component includes a method named
AcceptRequest that attempts to process new user requests for services. The
AcceptRequest component calls a private function named Validate.
You must ensure that any exceptions encountered by Validate are bubbled up
to the parent form of Request. The parent form will then be responsible for
handling the exceptions. You want to accomplish this while writing the
minimum amount of code.
What should you do?
Use the following code segment in AcceptRequest:
A) this.Validate();
B) try {
this.Validate();
}
catch(Exception ex) {
throw ex;
}
Answer: B
==========================================