Classes, objects, constructors, finalisers, the four pillars, and object relationships: composition, association, aggregation and dependency.
-
What is the difference between a class and an object in C#? Explain how an object is created with new, where it lives, what instance and static members belong to, and how object identity differs from object equality.
Classes as blueprints and objects as runtime instances: creation, memory, instance versus static members, identity and lifetime.
Junior
Theory
Core OOP
Β· π 3 follow-ups
-
How do constructors work in C#? Explain default and parameterised constructors, chaining with this() and base(), the order of initialisation in a class hierarchy, static constructors, primary constructors (C# 12) and required members, and why calling virtual methods from a constructor is dangerous.
Everything about object construction in C#: kinds of constructors, chaining, initialisation order, static and primary constructors, required members and pitfalls.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
Does C# have destructors? Explain finalisers, how the garbage collector runs them, why they are non-deterministic and costly, and how they relate to IDisposable, the dispose pattern and SafeHandle.
Finalisers in .NET: syntax, the finalisation queue, costs and risks, and why IDisposable and SafeHandle are the real tools for clean-up.
Senior
Theory
Core OOP
Β· π 3 follow-ups Β· π 1 real-world
-
What is encapsulation, and how do you apply it well in C#? Show the difference between a class that exposes its data and one that protects its invariants.
Encapsulation as protecting invariants: hiding state, exposing behaviour, and the C# tools that support it.
Junior
Theory
Core OOP
Β· π 2 follow-ups
-
What is abstraction in object-oriented programming, and how is it different from encapsulation? How do you design a good abstraction in C#, and what does a leaky or premature abstraction look like?
Abstraction as hiding complexity behind a simpler model, how it differs from encapsulation, and how to avoid leaky and premature abstractions.
Mid-Level
Theory
Core OOP
Β· π 3 follow-ups Β· π 1 real-world
-
How does inheritance work in C#? Explain single inheritance of classes, what a derived class inherits, base calls, member hiding with new versus overriding, protected members, and the problems that deep or misused inheritance causes.
Class inheritance in C#: mechanics, base calls, hiding versus overriding, protected access, the Liskov principle and common pitfalls.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is polymorphism in C#? Explain compile-time (overloading, generics) and run-time (virtual dispatch, interfaces) polymorphism, how virtual dispatch works under the hood, and how pattern matching relates to it.
Polymorphism in C#: the kinds, how virtual and interface dispatch work, and when to use polymorphism versus pattern matching.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is composition in object-oriented design? Show how a C# class can be built from smaller objects that it owns and delegates to, and explain the benefits for change, testing and reuse.
Composition as building objects from owned parts and delegating to them, with strategies and decorators as common forms.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is association between classes in object-oriented design? Explain multiplicity, direction (unidirectional versus bidirectional), how associations appear in C# code and EF Core, and the problems bidirectional associations cause.
Association as the general structural link between objects: multiplicity, navigability, C# and EF Core representation, and pitfalls.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is aggregation, and how does it differ from composition? Use examples to explain shared versus owned parts, lifetimes, deletion and cascade rules, and how the difference shows up in C# code and EF Core mappings.
Aggregation versus composition: whole/part relationships with shared or owned parts, and the consequences for lifetimes, deletes and persistence.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world
-
What is a dependency relationship between classes, and how is it different from association? Explain how dependencies appear in C# code, why direction matters (Dependency Inversion Principle), and how dependency injection manages them.
The 'uses' relationship: temporary dependencies versus stored associations, dependency direction and inversion, and DI in .NET.
Mid-Level
Theory
Core OOP
Β· π 2 follow-ups Β· π 1 real-world