Home / CSE MCQs / C#.Net MCQs :: C# Delegates, Generics and LINQ

CSE MCQs :: C#.Net MCQs

  1. Choose the statements which makes delegate in C#.NET different from a normal class?
  2. A.
    Delegates in C#.NET is a base class for all delegates type
    B.
    Delegates created in C#.NET are further not allowed to derive from the delegate types that are created
    C.
    Only system and compilers can derive explicitly from the Delegate or Multi caste Delegate class
    D.
    All of the mentioned

  3. Which of the following are the correct statements about delegates?
  4. A.
    Delegates can be used to implement callback notification
    B.
    Delegates permit execution of a method on a secondary thread in an asynchronous manner
    C.
    Delegate is a user defined type
    D.
    All of the mentioned

  5. Which among the following is the correct statement about delegate declaration ?

    delegate void del(int i);
  6. A.
    On declaring the delegate, a class called del is created
    B.
    the del class is derived from the MulticastDelegate class
    C.
    the del class will contain a one argument constructor and an invoke() method
    D.
    all of the mentioned

  7. Which of the following is an incorrect statement about delegate?
  8. A.
    A single delegate can invoke more than one method
    B.
    delegates could be shared
    C.
    delegates are type safe wrappers for function pointers
    D.
    delegate is a value type

  9. Select the type argument of an open constructed type?
  10. A.
    Gen
    B.
    Gen.
    C.
    Gen<>
    D.
    None of the mentioned

  11. Select the namespace which should be included while making use of LINQ operations:
  12. A.
    System.Text
    B.
    System.Collections.Generic
    C.
    System.Linq
    D.
    None of the mentioned

  13. Which of the following is a valid statement about generic procedures in C#.NET are?
  14. A.
    All procedures in a Generic class are generic
    B.
    Generic procedures should take at least one type parameter
    C.
    Only those procedures labeled as Generic are Generic
    D.
    None of the mentioned

  15. For the given set of codes, which query will work according to the set of code?

    class Program
    {
        static void Main(string[] args)
        {
            int[] nums = { 1, -2, 3, 0, -4, 5 };
            int len = /*_________________ */
            Console.WriteLine("The number of positive values in nums: " + len);
            Console.ReadLine();
        }
    }
  16. A.
    from n in nums where n > 0 select n
    B.
    from n in nums where n > 0 select n.Count()
    C.
    (from n in nums where n > 0 select n).Count();
    D.
    Both b & c

  17. Which among the given classes is present in System.Collection.Generic.namespace?
  18. A.
    Stack
    B.
    Tree
    C.
    Sorted Array
    D.
    All of the mentioned

  19. Select the output for the given code snippet:

    class Program
     {
         static void Main(string[] args)
         {
             int[] nums = { 1, -2, 3, 0, -4, 5 };
             var posNums = from n in nums
                           where n % 2 ==0
                           select n;
                Console.Write("The positive values in nums: ");
                foreach (int i in posNums) Console.Write(i + " ");
                Console.WriteLine();
                Console.ReadLine();
            }
        }
  20. A.
    code run successfully prints nothing
    B.
    run time error
    C.
    code run successfully and executes output
    D.
    compile time error