👉 Full lesson with practice questions on DevLadder (free, lesson 3 of 15 in the OOP Concepts in C# course)

Modifier Accessible from
public Everywhere
private Same class only (default for class members)
protected Same class and derived classes
internal Same assembly (default for top-level types)
protected internal Same assembly or derived classes anywhere
private protected Derived classes in the same assembly only
file (C# 11) Same source file (for types)

Interview tip: the default access for class members is private; for a top-level class it is internal.

Interview questions on OOP Concepts in C

What are the four pillars of OOP? Explain each with an example.

  1. Encapsulation: private state with a controlled public API. BankAccount keeps _balance private and exposes Deposit() that rejects negative amounts.
  2. Abstraction: expose what, hide how. IPaymentGateway.ChargeAsync() hides HTTP calls, signatures and retries.
  3. Inheritance: a derived class reuses and extends a base. Contractor : Employee reuses Name and Describe().
  4. Polymorphism: the same call behaves differently by type. employee.MonthlyPay() runs the Permanent or Contractor override at runtime.

What is the difference between a class and an object?

A class is a type definition (blueprint) describing fields, properties and methods; it exists in code and metadata. An object is an instance of that class created at runtime with new, occupying memory with its own state. One class, many objects.

What is the difference between method overloading and method overriding?

Overloading Overriding
Same name, different parameters Same signature in a derived class
Same class (or derived) Requires virtual/abstract + override
Resolved at compile time Resolved at runtime by the object's type
Return type alone can't differ Return type the same (covariant returns allowed since C# 9)

Read the full lesson with progress tracking and the rest of the course on DevLadder: free step-by-step tutorials and interview questions for developers.

Next in the course: Static members, static classes and partial classes →