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.

PrepAway - Latest Free Exam Questions & Answers

Answer: See the explanation

Explanation:
Target 1:

Target 2:

Target 3:

Target 4:

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

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

  1. Lord Vader says:

    6 4 1 3

    6 is given
    4
    use gettype() on an instance of the type:
    int myIntVariable =0;
    Type myType = myIntVariable.GetType();

    use typeof to pass in name of type: typeof(int)

    1 is given
    Type.getMethod(string): returns the public method with the specified name

    3
    after you have a reference to a method(methodinfo) you can execute the method by calling the invoke method of the methodinfo class by passing in the name of the method and its parameters

    4
    MethodBase.Invoke Method (Object, Object[])

    Invokes the method or constructor represented by the current instance, using the specified parameters.




    0



    0

Leave a Reply