C# Interview

Classes, Constructors & Properties

C# interview questions covering classes, constructors & properties.

10 Questions Filter by level

Interview questions

Open a question for the full answer, code and interview guidance.

10 Results
21
JuniorBeginner

What is a constructor in C#?

A constructor is a special member of a class that runs automatically when an object is created. It has the same name as the class and has no return type.

22
JuniorBeginner

What are the different types of constructors in C#?

Common constructor forms include parameterless constructors, parameterized constructors, static constructors, and private constructors.

23
JuniorBeginner

What is constructor overloading?

Constructor overloading means defining multiple constructors in the same class with different parameter lists. It allows callers to create objects using different sets of initialization data.

24
JuniorBeginner

What is constructor chaining in C#?

Constructor chaining means one constructor calls another constructor. The this keyword calls another constructor in the same class, while base calls a constructor in the base class.

25
JuniorBeginner

What are access modifiers in C#?

Access modifiers determine where a type or member can be accessed.

26
JuniorBeginner

What is a property in C#?

A property provides accessor-based access to data exposed by a class or struct. Properties normally use get, set, or init accessors.

27
JuniorBeginner

What is the difference between a field and a property?

A field is a variable declared directly inside a class or struct. A property is a member that exposes access through get, set, or init accessors.

28
JuniorBeginner

What is the static keyword in C#?

A static member belongs to the type itself rather than to an individual object instance. It can therefore be accessed through the type name without creating an object.

29
JuniorBeginner

What is a sealed class in C#?

A sealed class cannot be inherited. It is useful when a type's behavior should not be extended through class inheritance.

30
JuniorBeginner

What is a partial class in C#?

A partial class allows one class definition to be split across multiple source files. At compile time, the parts are combined into a single type.