1. Question: Which of the following is true about friend functions in C#?

    A
    Friend functions violate the concept of OOPS.

    B
    Friend functions should not be used.

    C
    Friend functions enhance the concept of OOPS if used properly.

    D
    Friend functions are not available in C#.

    Note: Not available
    1. Report
  2. Question: Which of the following statements is true about the code below?
    string[] lines = theText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

    A
    It splits the string variable on a system line break.

    B
    It splits the string variable on a ā€˜\r\nā€™ line break.

    C
    It splits the string variable on a system line break, while preserving the empty lines.

    D
    It splits the string variable on a system line break, while removing the empty lines.

    Note: Not available
    1. Report
  3. Question: Consider the following code:
    string s1 = "Old Value";
    string s2 = s1;
    s1 = "New Value";
    Console.WriteLine(s2);
    What will be the output printed, and why?

    A
    "New Value", because string is a reference type.

    B
    "Old Value", because string is a value type.

    C
    "New Value", because string is a value type.

    D
    "Old Value", because string is a reference type

    E
    "Old Value", because string is a reference type which is treated as a special case by the assignment operator.

    Note: Not available
    1. Report
  4. Question: What will be the output if in a WinForms application, the following code is executed in the Load event of a form? Assume this form has lblMessage as a Label Control.
    private void Form1_Load(object sender, EventArgs e)
    {
        try
        {
            ThreadPool.QueueUserWorkItem(ShowMessage,null);
        }
        catch (Exception ex)
        {
        }
    }
    
    private void ShowMessage(object obj)
    {
        try
        {
            lblMessage.Text = "Hello from Thread Pool";
        }
        catch (Exception ex)
        {
        }
    }

    A
    lblMessage.Text will be set to "Hello from Thread Pool".

    B
    An InvalidOperationException will be thrown for the function ShowMessage as the UI can be updated only from the UI thread.

    C
    Behavior will vary depending on the form loaded.

    D
    None of these.

    Note: Not available
    1. Report
  5. Question: Where does a C# assembly store the information regarding the other external dependencies, such as satellite assemblies, global assemblies etc, and their versions so that they can be loaded correctly when the assembly is executed?

    A
    In the embedded resources of the assembly

    B
    In the manifest of the assembly

    C
    In the MSIL of the assembly

    D
    In the Windows registry database

    E
    None of these

    Note: Not available
    1. Report
  6. Question: Which of the following will output the string below? "ttttt"

    A
    private string Tabs(uint numTabs) { IEnumerable<string> tabs = Enumerable.Repeat("t", numTabs); return (numTabs > 0) ? tabs.Aggregate((sum, next) => sum + next) : ""; }

    B
    private string Tabs(uint numTabs) { StringBuilder sb = new StringBuilder(); for (uint i = 0; i <= numTabs; i++) { sb.Append("t"); } return sb.ToString(); }

    C
    private string Tabs(uint numTabs) { string output = ""; for (uint i = 0; i <= numTabs; i++) { output += 't'; } return output; }

    D
    private string Tabs(uint numTabs) { String output = new String('t', numTabs); return output; }

    Note: Not available
    1. Report
  7. Question: Complete the following sentence: In C#, exception handling should be used...

    A
    to handle the occurrence of unusual or unanticipated program events

    B
    to redirect the programs normal flow of control

    C
    in cases of potential logic or user input errors

    D
    in case of overflow of an array boundary

    Note: Not available
    1. Report
  8. Question: Which statements will give the path where the executing assembly is currently located?

    A
    System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

    B
    System.Reflection.Assembly.GetExecutingAssembly().Location;

    C
    AppDomain.CurrentDomain.BaseDirectory;

    D
    None of these

    Note: Not available
    1. Report
  9. Question: In C#, can global functions that are not associated with a particular class be defined?

    A
    Yes

    B
    Yes, but they have to be marked with the keyword static.

    C
    Yes, but they have to be marked with the keyword internal.

    D
    No

    Note: Not available
    1. Report
  10. Question: Which of the following code snippets will call a generic method when the type parameter is not known at compile time?

    A
    var name = InvokeMemberName.Create; Impromptu.InvokeMemberAction(this, name("GenericMethod", new[]{myType}));

    B
    MethodInfo method = typeof(Sample).GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);

    C
    Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod(GenMethod.Method.Name); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);

    D
    Action<> GenMethod = GenericMethod< myType >; MethodInfo method = this.GetType().GetMethod("GenericMethod"); MethodInfo generic = method.MakeGenericMethod(myType); generic.Invoke(this, null);

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd