1. Question: What is the output of the following code:
    class CCheck {
    
        public static void Main() {
            string str = @"E:\\RIL\\test.cs";
            Console.WriteLine(str);
        }
    }

    A
    "E:\\RIL\\test.cs"

    B
    E:\\RIL\\test.cs

    C
    "E:\RIL\test.cs"

    D
    The compiler will generate an error saying undefined symbol '@'.

    Note: Not available
    1. Report
  2. Question: What is the issue with the following function?
    public string GetName(int iValue)
    {
        string sValue = "0";
        switch (iValue)
        {
            case 1:
                sValue = iValue.ToString();
            case 2:
                sValue = iValue.ToString();
                break;
            default:
                sValue = "-1";
                break;
        }
        return sValue;
    }

    A
    The code will not compile as there shouldn't be a break statement in the default case label.

    B
    The code will compile but if case 1 is passed as the input parameter to the function, the code for case 2 will also execute (after the code for case 1), and so the wrong value may be returned.

    C
    The code will compile and run without any issues.

    D
    The code will not compile as there is no break statement in case 1.

    Note: Not available
    1. Report
  3. Question: What will be the output of the following Main program in a C# console application (Assume required namespaces are included):
    static void Main(string[] args)
    {
        for (int i = 0; i < 1; i++)
        {
            Console.WriteLine("No Error");
        }
        int A = i;
        Console.ReadLine();
    }

    A
    No Error

    B
    This program will throw a compilation error, "The name 'i' does not exist in the current context".

    C
    The program will compile, but throw an error at runtime.

    D
    None of these.

    Note: Not available
    1. Report
  4. Question: What is the difference between int and System.Int32 CLR types?

    A
    int represents a 16-bit integer while System.Int32 represents a 32-bit integer.

    B
    int is just an alias for System.Int32, there is no difference between them.

    C
    int represents a 64-bit integer while Int32 represents a 32-bit integer.

    D
    None of these.

    Note: Not available
    1. Report
  5. Question: What will be the return value if the function fn is called with a value of 50 for the parameter var?
    public int fn(int var)
    {
        int retvar = var - (var / 10 * 5);
        return retvar;
    }

    A
    50

    B
    25

    C
    49

    D
    Error message

    E
    None of these

    Note: Not available
    1. Report
  6. Question: Which of the following code snippets converts an IEnumerable<string> into a string containing comma separated values?

    A
    public static string ConvertToString(IEnumerable<T> source) { return new List<T>(source).ToArray(); }

    B
    public static string ConvertToString(IEnumerable<T> source) { return string.Join(",",source.ToArray()); }

    C
    public static string ConvertToString(IEnumerable<T> source) { return source.ToString(); }

    D
    public static string ConvertToString(IEnumerable<T> source) { return string.Join(source.ToArray()); }

    Note: Not available
    1. Report
  7. Question: Which of the following is true regarding a null and an empty collection in C#?

    A
    An empty collection and a null are both objects.

    B
    An empty collection and a null both have the same meaning.

    C
    Both an empty collection and a null do not refer to any object.

    D
    An empty collection is an object while the null keyword is a literal.

    Note: Not available
    1. Report
  8. Question: Which of the following exceptions cannot be thrown by the Delete() function of the FileInfo class (ie. FileInfo.Delete())?

    A
    IOException

    B
    SecurityException

    C
    UnauthorizedAccessException

    D
    InvalidOperationException

    Note: Not available
    1. Report
  9. Question: Which of the following statements are true regarding the ref and out parameters in C#?

    A
    A variable that is passed as an out parameter needs to be initialized, but the method using the out parameter does not need to set it to something.

    B
    The out parameter can be used to return the values in the same variable passed as a parameter of the method. Any changes made to the parameter will be reflected in the variable.

    C
    The ref keyword can only be used on one method parameter.

    D
    The ref parameter is considered initially assigned by the callee. As such, the callee is not required to assign to the ref parameter before use. Ref parameters are passed both into and out of a method.

    Note: Not available
    1. Report
  10. Question: What is the difference between the String and StringBuilder class objects with respect to mutability?

    A
    String objects are mutable, while StringBuilder objects are immutable.

    B
    String objects are immutable, while StringBuilder objects are mutable.

    C
    There is no difference between them in this context, as both are immutable.

    D
    There is no difference between them in this context, as both are mutable.

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