Constructors Questions and Answers

Take Exam

Constructors questions with answers are among the most common topics in C# programming interviews and tests. Constructors are special methods used to initialize objects, ensuring that new instances are set up correctly. This compilation of programming questions and answers covers default, parameterized, static, and copy constructors in C#. Ideal for candidates preparing for C programming MCQs and technical interviews at TCS, Wipro, and HCL, this section also includes practical code examples and explanations. Practicing constructors programming interview questions with answers enhances your coding proficiency and readiness for software development roles.

Learn about constructors in object-oriented programming. Also review destructors and inheritance concepts

Constructors

Showing 10 of 15 questions

11. Which of the following statements are correct about the C#.NET code snippet given below? class Sample {     static int i;     int j;     public void proc1()     {         i = 11;         j = 22;     }     public static void proc2()     {         i = 1;         j = 2;     }     static Sample()     {         i = 0;         j = 0;     } }

  • i cannot be initialized in proc1().
  • proc1() can initialize i as well as j.
  • j can be initialized in proc2().
  • The constructor can never be declared as static.
Show Answer Report

12. Which of the following statements is correct?

  • There is one garbage collector per program running in memory.
  • There is one common garbage collector for all programs.
  • An object is destroyed by the garbage collector when only one reference refers to it.
  • We have to specifically run the garbage collector after executing Visual Studio.NET.
Show Answer Report

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

  • Yes
  • No
Show Answer Report

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

  • Static functions are invoked using objects of a class.
  • Static functions can access static data as well as instance data.
  • Static functions are outside the class scope.
  • Static functions are invoked using class.
Show Answer Report

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

  • A constructor cannot be declared as private.
  • A constructor cannot be overloaded.
  • A constructor can be a static constructor.
  • A constructor cannot access static data.
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test