PrepAway - Latest Free Exam Questions & Answers

Which code should you insert at line 16?

DRAG DROP
You have the following class. (Line numbers are included for reference only.)

You need to complete the doOperation method to meet the following requirements:
If AddNumb is passed as the operationName parameter, the AddNumb function is called.
If SubNumb is passed as the operationName parameter, the SubNumb function is called.
Which code should you insert at line 16? Develop the solution by selecting and arranging the required code
blocks in the correct order. You may not need all of the code blocks.
Select and Place:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
Note:
* target 2:
GetType() is a method you call on individual objects, to get the execution-time type of the object.
Incorrect: typeof is an operator to obtain a type known at compile-time (or at least a generic type parameter).
The operand of typeof is always the name of a type or type parameter – never an expression with a value (e.g. a
variable). See the C# language specification for more details.
What is the difference of getting Type by using GetType() and typeof()?
http://stackoverflow.com/questions/11312111/when-and-where-to-use-gettype-or-typeof

2 Comments on “Which code should you insert at line 16?

  1. ssss says:

    answer is:

    MyClass myClassObj = new MyClass();
    Type myTypeObj = myClassObj.GetType();
    MethodInfo myMethodInfo = myTypeObj.GetMethod(operationName);
    return myMethodInfo.Invoke(myClassObj, mParam).ToString();




    1



    0

Leave a Reply