Bird
Raised Fist0

Which of the following is a correct constructor overloading syntax in C#?

easy📝 Syntax Q12 of Q15
C Sharp (C#) - Classes and Objects
Which of the following is a correct constructor overloading syntax in C#?
Apublic class Car { public Car() {} public Car(string model) {} }
Bpublic class Car { public void Car() {} public void Car(string model) {} }
Cpublic class Car { public Car() {} public Car() {} }
Dpublic class Car { Car() {} Car() {} }
Step-by-Step Solution
Solution:
  1. Step 1: Check constructor syntax

    Constructors must have the same name as the class and no return type.
  2. Step 2: Identify correct overloading

    public class Car { public Car() {} public Car(string model) {} } has two constructors with different parameters and correct syntax.
  3. Final Answer:

    public class Car { public Car() {} public Car(string model) {} } -> Option A
  4. Quick Check:

    Constructor syntax correct and overloaded by parameters [OK]
Quick Trick: Constructors have no return type and match class name [OK]
Common Mistakes:
MISTAKES
  • Adding return type to constructors
  • Defining multiple constructors with same parameters
  • Omitting access modifier (not mandatory but common style)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

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