1. Which of the following statements is correct?  

  • A) A constructor can be used to set default values and limit instantiation.
  • B) C# provides a copy constructor.
  • C) Destructors are used with classes as well as structures.
  • D) A class can have more than one destructor.
  • E) All of these.

2. Which of the following statements is correct about constructors?  

  • A) If we provide a one-argument constructor then the compiler still provides a zero-argument constructor.
  • B) Static constructors can use optional arguments.
  • C) If we do not provide a constructor, then the compiler provides a zero-argument constructor.
  • D) Overloaded constructors cannot use optional arguments.
  • E) None of these.

3. In which of the following should the methods of a class differ if they are to be treated as overloaded methods?  

  • A) Type of arguments
  • B) Return type of methods
  • C) Number of arguments
  • D) Names of methods
  • E) Order of arguments

4. Which of the following statements are correct about constructors in C#.NET?  

  • A) Constructors cannot be overloaded.
  • B) Constructors always have the name same as the name of the class.
  • C) Constructors are never called explicitly.
  • D) Constructors never return any value.
  • E) Constructors allocate space for the object in memory.

5. How many times can a constructor be called during lifetime of the object?  

  • A) As many times as we call it.
  • B) Only once.
  • C) Depends upon a Project Setting made in Visual Studio.NET.
  • D) Any number of times before the object gets garbage collected.
  • E) Any number of times before the object is deleted.

6. Is it possible to invoke Garbage Collector explicitly?  

  • A) No.
  • B) Yes.

7. Which of the following statements is correct?  

  • A) There is one garbage collector per program running in memory.
  • B) An object is destroyed by the garbage collector when only one reference refers to it.
  • C) There is one common garbage collector for all programs.
  • D) We have to specifically run the garbage collector after executing Visual Studio.NET.
  • E) None of these.

8. Is it possible for you to prevent an object from being created by using zero argument constructor?  

  • A) Yes.
  • B) No.

9. Which of the following statements are correct about static functions?  

  • A) Static functions are invoked using class.
  • B) Static functions are invoked using objects of a class.
  • C) Static functions can access static data as well as instance data.
  • D) Static functions are outside the class scope.
  • E) All of these.

10. Which of the following statements is correct about constructors in C#.NET?  

  • A) A constructor cannot be declared as private.
  • B) this reference is never passed to a constructor.
  • C) A constructor cannot be overloaded.
  • D) A constructor cannot access static data.
  • E) A constructor can be a static constructor.

11. What will be the output of the C#.NET code snippet given below?
namespace DesignGoDynamic
    class DGD
        static DGD()
            Console.Write("DGD class ");
        public static void DGD1 ()
            Console.Write("DGD1 method ");
    class MyProgram
        static void Main(string[ ] args)
            DGD .DGD1 ();

  • A) DGD class DGD1 method
  • B) DGD1 method
  • C) DGD class
  • D) DGD1 method DGD class
  • E) DGD class DGD class

12. what is a Constructor ?  

Constructor is a method that is called when an instance of an object is created. They have the same name as a class. eg- class Test { public Test() { } }

13. Can a constructor have access modifier ?  

Yes .The foll are access modifiers allowed - 1.Public --This is called whenever a class is initialized. 2.Private- This will prevent the class from being instantiated(creating objects) 3.Protected- 4.Internal--cannot be instantiated outside the assembly.

14. If a class has parametrized constructor do we need to have default constructor?  

c# provides a default constructor with no parameters if there are no explicit ones. But if we have a parameterized constructor we need to specify a defualt one with no parameters.

15. .Can constructors be inherited ?  


16. How can you call a base class constructor from a child class ?  

Child class can call base class constructor by using the keyword base.

17. Can constructors be overloaded ?  


18. When you create an object of the above class which constructor is called first ?  

When you instantiate the above class first overloaded constructor is called and then the default one is called.

19. Can a constructor call itself by using this keyword ?  

N0 it will through an compile time error.

20. Does memory gets allocated when constructor is called ?  

Yes using new operator.

.Net Interview Question

PHP Interview Question

Java Interview Question

AngularJS Interview Questions