Bird
Raised Fist0

Why does the new keyword in C# always call a constructor when creating an object?

hard🧠 Conceptual Q10 of Q15
C Sharp (C#) - Classes and Objects
Why does the new keyword in C# always call a constructor when creating an object?
ATo allocate memory and initialize the object properly.
BTo convert the object to a string representation.
CTo delete any existing objects with the same name.
DTo declare a variable without assigning a value.
Step-by-Step Solution
Solution:
  1. Step 1: Understand purpose of constructor call

    The constructor sets up the object's initial state after memory allocation.
  2. Step 2: Recognize why constructor is mandatory

    Without calling the constructor, the object would be uninitialized and unusable.
  3. Final Answer:

    To allocate memory and initialize the object properly. -> Option A
  4. Quick Check:

    new calls constructor to initialize object [OK]
Quick Trick: new calls constructor to set up object [OK]
Common Mistakes:
MISTAKES
  • Thinking new converts or deletes objects
  • Assuming new only declares variables
  • Confusing new with assignment

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More C Sharp (C#) Quizzes