PrepAway - Latest Free Exam Questions & Answers

What are two possible ways to achieve this goal?

You are testing an application. The application includes methods named CalculateInterest and
LogLine. The CalculateInterest() method calculates loan interest. The LogLine() method sends
diagnostic messages to a console window.
The following code implements the methods. (Line numbers are included for reference only.)

You have the following requirements:
The Calculatelnterest() method must run for all build configurations.
The LogLine() method must run only for debug builds.
You need to ensure that the methods run correctly.
What are two possible ways to achieve this goal? (Each correct answer presents a complete solution.
Choose two.)

PrepAway - Latest Free Exam Questions & Answers

A.
Insert the following code segment at line 01:
#region DEBUG
Insert the following code segment at line 10:
#endregion

B.
Insert the following code segment at line 10:
[Conditional(MDEBUG”)]

C.
Insert the following code segment at line 05:
#region DEBUG
Insert the following code segment at line 07:
#endregion

D.
Insert the following code segment at line 01:
#if DE30G
Insert the following code segment at line 10:
#endif

E.
Insert the following code segment at line 01:
[Conditional(MDEBUG”)]

F.
Insert the following code segment at line 05:
#if DEBUG
Insert the following code segment at line 07:

#endif

G.
Insert the following code segment at line 10:
[Conditional(“RELEASE”)]

Explanation:
#if DEBUG: The code in here won’t even reach the IL on release.
[Conditional(“DEBUG”)]: This code will reach the IL, however the calls to the method will not execute
unless DEBUG is on.
http://stackoverflow.com/questions/3788605/if-debug-vs-conditionaldebug

2 Comments on “What are two possible ways to achieve this goal?

  1. A says:

    [Conditional(“DEBUG”)]
    public void Debug( string msg )
    {
    // this is where the debug statement display code would be
    }
    What this will do is when this program is compiled it will check if ‘DEBUG’ was #defined and if it was then the call to this function will be remain, however if ‘DEBUG’ is not #defined all calls to this function not will be compiled leaving us with no performance hit




    0



    0

Leave a Reply