1.

You develop a Windows-based application that enables to enter product sales. You add a subroutine named XYZ._x005F_x000D_  _x005F_x000D_ You discover that XYZ sometimes raises an IOException during execution. To address this problem you create two additional subroutines named LogError and CleanUp. These subroutines are governed by the following rules:_x005F_x000D_ • LogError must be called only when XYZ raises an exception.• CleanUp must be called whenever XYZ is complete._x005F_x000D_  _x005F_x000D_  You must ensure that your application adheres to these rules. Which code segment should you use?

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» D. try { XYZ(); } catch (Exception e) { CleanUp(e); } finally { LogError(); }


Discussion

No Comment Found