0
Q:
A) try { XYZ(); LogError(); } catch (Exception e) { CleanUp(e); } | B) try { XYZ(); } catch (Exception e) { LogError(e); CleanUp(); } |
C) try { XYZ(); } catch (Exception e) { LogError(e); } finally { CleanUp(); } | D) try { XYZ(); } catch (Exception e) { CleanUp(e); } finally { LogError(); } |
Answer: C) try { XYZ(); } catch (Exception e) { LogError(e); } finally { CleanUp(); }
Explanation:
Explanation:
We must use a try…catch…finally construct. First we run the Comapany() code in the try block.Then we use the LogError() subroutine in the catch statement since all exceptions are handled here. Lastly we put the CleanUp() subroutine in the finally statement since this code will be executed regardless of whether an exception is thrown or not.