Technical interview questions with detailed answers—organized by course, like Dot Net Tutorials interview sections. Original content for Toolliyo Academy.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
contain data (fields/properties) and behavior (methods/functions).
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
programming lacks.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
class Vehicle {} // Base
class Car : Vehicle {} // Single/Multilevel
class Bike : Vehicle {} // Hierarchical
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
public class Car
public string Model { get; set; }
public void Start() { Console.WriteLine("Car started"); }
C# OOP C# Programming Tutorial · OOP
Car myCar = new Car(); // Object of Car class
C# OOP C# Programming Tutorial · OOP
Feature Class Object
Definition Blueprint/Template Instance of a class
Memory Does not occupy
memory
Occupies memory
Example class Car { } Car myCar = new
Car();
C# OOP C# Programming Tutorial · OOP
public class Car
public string Model;
public Car(string model) { Model = model; }
Car car = new Car("Tesla");
C# OOP C# Programming Tutorial · OOP
~Car() { Console.WriteLine("Car object destroyed"); }
C# OOP C# Programming Tutorial · OOP
public class Car
public string Model; // Instance
public static int Count; // Static
C# OOP C# Programming Tutorial · OOP
functionality through access modifiers and properties.
private int speed;
public int Speed
get { return speed; }
set { speed = value; }
C# OOP C# Programming Tutorial · OOP
object.
abstract class Vehicle
public abstract void Start();
C# OOP C# Programming Tutorial · OOP
Vehicle v = new Car();
v.Start(); // Run-time polymorphism
C# OOP C# Programming Tutorial · OOP
action.
🔹 Section 2: Encapsulation – Interview Q&A
C# OOP C# Programming Tutorial · OOP
exposing only necessary functionalities.
modified.
Example: A BankAccount class hides its balance and only allows deposit/withdraw
operations:
private decimal balance;
public void Deposit(decimal amount) { if(amount > 0) balance +=
amount; }
C# OOP C# Programming Tutorial · OOP
Example: Prevent withdrawing more than the account balance:
public void Withdraw(decimal amount)
if (amount <= balance) balance -= amount;
else throw new InvalidOperationException("Insufficient
balance");
C# OOP C# Programming Tutorial · OOP
private int age;
public int Age
get { return age; }
set { if (value > 0) age = value; }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Example:
private decimal balance; // hidden
public decimal Balance { get { return balance; } } // read-only
access
C# OOP C# Programming Tutorial · OOP
Example:
protected string accountType; // accessible in derived classes
internal string branchCode; // accessible within same assembly
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Example:
private int score;
public int Score
get { return score; }
set { if (value >= 0) score = value; } // validation
C# OOP C# Programming Tutorial · OOP
systems.
C# OOP C# Programming Tutorial · OOP
Real-World Example: Bank Account Management
public class BankAccount
private string accountNumber; // private field
private decimal balance; // private field
public string AccountNumber { get { return accountNumber; } } //
read-only
public decimal Balance { get { return balance; } } //
read-only
public BankAccount(string accNum, decimal initialBalance)
accountNumber = accNum;
balance = initialBalance >= 0 ? initialBalance : throw new
ArgumentException("Invalid balance");
public void Deposit(decimal amount)
if(amount > 0) balance += amount;
else throw new ArgumentException("Deposit must be
positive");
public void Withdraw(decimal amount)
if(amount > 0 && amount <= balance) balance -= amount;
else throw new InvalidOperationException("Insufficient
balance");
// Usage
BankAccount myAccount = new BankAccount("ACC123", 1000);
myAccount.Deposit(500); // Balance becomes 1500
myAccount.Withdraw(200); // Balance becomes 1300
Console.WriteLine($"Account: {myAccount.AccountNumber}, Balance:
{myAccount.Balance}");
Explanation:
🔹 Section 3: Abstraction – Interview Q&A
C# OOP C# Programming Tutorial · OOP
system and exposing only the essential features.
Example: A Vehicle class exposes Start() method without revealing engine details.
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
abstract class Vehicle
public abstract void Start();
interface IDriveable
void Drive();
C# OOP C# Programming Tutorial · OOP
(without implementation).
abstract class Animal
public abstract void MakeSound();
public void Sleep() => Console.WriteLine("Sleeping");
C# OOP C# Programming Tutorial · OOP
classes must follow.
methods).
interface IFlyable
void Fly();
C# OOP C# Programming Tutorial · OOP
and decoupling.
class Bird : IFlyable
public void Fly() => Console.WriteLine("Bird is flying");
class Airplane : IFlyable
public void Fly() => Console.WriteLine("Airplane is flying");
C# OOP C# Programming Tutorial · OOP
Feature Abstract Class Interface
Methods Can have abstract +
concrete methods
Only abstract methods (C# 8+ allows default
implementation)
Fields Can have fields Cannot have fields
Inheritance Single inheritance Multiple interfaces can be implemented
Constructo
Can have constructors Cannot have constructors
C# OOP C# Programming Tutorial · OOP
abstract class Shape { public abstract void Draw(); }
// Shape s = new Shape(); // Not allowed
class Circle : Shape { public override void Draw() =>
Console.WriteLine("Circle"); }
C# OOP C# Programming Tutorial · OOP
abstract class Animal
public void Sleep() => Console.WriteLine("Sleeping");
public abstract void MakeSound();
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Real-World Example: Payment Processing
// Abstract class
abstract class Payment
public abstract void Pay(decimal amount);
public void ShowReceipt(decimal amount) =>
Console.WriteLine($"Paid: {amount:C}");
// Derived classes implement abstraction
class CreditCardPayment : Payment
public override void Pay(decimal amount) =>
Console.WriteLine($"Paid {amount:C} using Credit Card");
class PayPalPayment : Payment
public override void Pay(decimal amount) =>
Console.WriteLine($"Paid {amount:C} using PayPal");
// Usage
Payment payment1 = new CreditCardPayment();
payment1.Pay(500);
payment1.ShowReceipt(500);
Payment payment2 = new PayPalPayment();
payment2.Pay(300);
payment2.ShowReceipt(300);
Explanation:
made.
🔹 Section 4: Inheritance – Interview Q&A
C# OOP C# Programming Tutorial · OOP
properties and methods from another class (base/parent).
class Vehicle { public void Start() => Console.WriteLine("Vehicle
started"); }
class Car : Vehicle { } // Car inherits from Vehicle
C# OOP C# Programming Tutorial · OOP
class Vehicle { public void Start() {} } // Base
class Car : Vehicle {} // Derived
C# OOP C# Programming Tutorial · OOP
class Vehicle { public void Start() => Console.WriteLine("Start"); }
class Car : Vehicle { }
Car myCar = new Car();
myCar.Start(); // Inherited method
C# OOP C# Programming Tutorial · OOP
class Vehicle { public Vehicle(string brand) {
Console.WriteLine(brand); } }
class Car : Vehicle
public Car(string brand) : base(brand) { Console.WriteLine("Car
created"); }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
interface IFlyable { void Fly(); }
interface IDriveable { void Drive(); }
class FlyingCar : IFlyable, IDriveable { public void Fly() {} public
void Drive() {} }
C# OOP C# Programming Tutorial · OOP
Feature Inheritance Composition
Relationship "is-a" "has-a"
Reuse Derived class reuses base
class
Object contains other
objects
Flexibility Less flexible More flexible
Example:
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
sealed class FinalClass { }
class Car : FinalClass { } // Not allowed
C# OOP C# Programming Tutorial · OOP
class Vehicle { public void Start() => Console.WriteLine("Vehicle");
class Car : Vehicle { public new void Start() =>
Console.WriteLine("Car"); }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Review the concept and prepare a concise verbal explanation with a real project example.
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
class Vehicle { private int id; protected string model; }
class Car : Vehicle { /* cannot access id, can access model */ }
🔹 Section 5: Polymorphism – Interview Q&A
C# OOP C# Programming Tutorial · OOP
type.
C# OOP C# Programming Tutorial · OOP
class Calculator
public int Add(int a, int b) => a + b;
public double Add(double a, double b) => a + b; // Overloaded
method
C# OOP C# Programming Tutorial · OOP
class Vehicle { public virtual void Start() =>
Console.WriteLine("Vehicle starts"); }
class Car : Vehicle { public override void Start() =>
Console.WriteLine("Car starts"); }
Vehicle v = new Car();
v.Start(); // Calls Car's Start() at runtime
C# OOP C# Programming Tutorial · OOP
class MathHelper
public int Multiply(int a, int b) => a * b;
public int Multiply(int a, int b, int c) => a * b * c; //
Overloaded
C# OOP C# Programming Tutorial · OOP
class Vehicle { public virtual void Start() =>
Console.WriteLine("Vehicle starts"); }
class Car : Vehicle { public override void Start() =>
Console.WriteLine("Car starts"); }
C# OOP C# Programming Tutorial · OOP
class Car
public Car() { }
public Car(string model) { }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
class Point
public int X, Y;
public static Point operator +(Point a, Point b) => new Point {
X = a.X + b.X, Y = a.Y + b.Y };
C# OOP C# Programming Tutorial · OOP
Feature Overloading Overriding
Compile/Runtime Compile-time Runtime
Same signature? No, different parameters Same
signature
Virtual required? No Yes
Inheritance
required?
Not required Required
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
object obj = new Car();
C# OOP C# Programming Tutorial · OOP
abstract class Shape { public abstract void Draw(); }
class Circle : Shape { public override void Draw() =>
Console.WriteLine("Drawing Circle"); }
class Rectangle : Shape { public override void Draw() =>
Console.WriteLine("Drawing Rectangle"); }
Shape s1 = new Circle();
Shape s2 = new Rectangle();
s1.Draw(); // Circle's Draw
s2.Draw(); // Rectangle's Draw
C# OOP C# Programming Tutorial · OOP
dynamic behavior at runtime.
interface IDriveable { void Drive(); }
class Car : IDriveable { public void Drive() =>
Console.WriteLine("Car drives"); }
class Bike : IDriveable { public void Drive() =>
Console.WriteLine("Bike drives"); }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
void StartVehicle(Vehicle v) { v.Start(); } // Works with any
derived type
C# OOP C# Programming Tutorial · OOP
Advantages:
Disadvantages:
🔹 Section 6: Interfaces in C# – Interview Q&A
C# OOP C# Programming Tutorial · OOP
indexers without providing implementation.
C# OOP C# Programming Tutorial · OOP
interface IDriveable
void Drive();
int Speed { get; set; }
C# OOP C# Programming Tutorial · OOP
class Car : IDriveable
public int Speed { get; set; }
public void Drive() => Console.WriteLine("Car is driving");
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
interface IUtility
static void Show() => Console.WriteLine("Static method in
interface");
C# OOP C# Programming Tutorial · OOP
interface ILogger
void Log(string message);
void LogWarning(string message) => Console.WriteLine("Warning: "
+ message);
C# OOP C# Programming Tutorial · OOP
Feature Interface Class
Implementatio
No implementation (except default
methods)
Can have full
implementation
Fields Cannot have fields Can have fields
Instantiation Cannot instantiate Can instantiate
Inheritance Can inherit multiple interfaces Single class inheritance only
C# OOP C# Programming Tutorial · OOP
class FlyingCar : IDriveable, IFlyable
public void Drive() => Console.WriteLine("Driving");
public void Fly() => Console.WriteLine("Flying");
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
separately.
class Car : IDriveable
void IDriveable.Drive() => Console.WriteLine("Explicit drive");
C# OOP C# Programming Tutorial · OOP
reference, not class object.
IDriveable car = new Car();
car.Drive(); // Works
// Car c = new Car(); c.Drive(); // Won't compile
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
void StartVehicle(IDriveable vehicle) { vehicle.Drive(); }
C# OOP C# Programming Tutorial · OOP
public class CarService
private readonly IDriveable _vehicle;
public CarService(IDriveable vehicle) { _vehicle = vehicle; }
C# OOP C# Programming Tutorial · OOP
class Employee : IComparable<Employee>
public int Id { get; set; }
public int CompareTo(Employee other) =>
this.Id.CompareTo(other.Id);
C# OOP C# Programming Tutorial · OOP
class FileHandler : IDisposable
public void Dispose() => Console.WriteLine("Resources
released");
C# OOP C# Programming Tutorial · OOP
method).
Reset()).
C# OOP C# Programming Tutorial · OOP
interface IFlyable { void Fly(); }
interface IAdvancedFlyable : IFlyable { void Loop(); }
C# OOP C# Programming Tutorial · OOP
behavior.
🔹 Section 7: Abstract Classes in C# – Interview Q&A
C# OOP C# Programming Tutorial · OOP
(with implementation).
C# OOP C# Programming Tutorial · OOP
abstract class Vehicle
public abstract void Start();
public void Stop() => Console.WriteLine("Vehicle stopped");
C# OOP C# Programming Tutorial · OOP
abstract class Vehicle
public abstract void Start();
class Car : Vehicle
public override void Start() => Console.WriteLine("Car
started");
C# OOP C# Programming Tutorial · OOP
abstract class Vehicle
protected string Brand;
C# OOP C# Programming Tutorial · OOP
abstract class Vehicle
protected string Brand;
public Vehicle(string brand) { Brand = brand; }
class Car : Vehicle
public Car(string brand) : base(brand) { }
C# OOP C# Programming Tutorial · OOP
interface IDriveable { void Drive(); }
abstract class Vehicle : IDriveable { public abstract void Drive();
class Car : Vehicle { public override void Drive() =>
Console.WriteLine("Car drives"); }
C# OOP C# Programming Tutorial · OOP
inherited.
C# OOP C# Programming Tutorial · OOP
access them.
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Feature Abstract Method Virtual Method
Implementatio
No implementation Has implementation
Must override? Must be overridden Optional to override
Class type Must be in abstract class Can be in any class
Purpose Force derived classes to
implement
Allow derived class to optionally
override
C# OOP C# Programming Tutorial · OOP
abstraction.
C# OOP C# Programming Tutorial · OOP
abstract class Employee
public string Name { get; set; }
public abstract void Work();
public void Report() => Console.WriteLine("Reporting work
done");
class Developer : Employee
public override void Work() => Console.WriteLine("Writing
code");
class Tester : Employee
public override void Work() => Console.WriteLine("Testing
application");
// Usage
Employee dev = new Developer() { Name = "Alice" };
dev.Work();
dev.Report();
C# OOP C# Programming Tutorial · OOP
Feature Abstract Class Normal Class
Instantiation Cannot instantiate Can instantiate
Methods Can have abstract methods All methods must have implementation
Purpose Serve as base for
inheritance
General purpose use
C# OOP C# Programming Tutorial · OOP
subclasses.
abstract class Vehicle { public abstract void Start(); }
class Car : Vehicle { public override void Start() =>
Console.WriteLine("Car starts"); }
C# OOP C# Programming Tutorial · OOP
interface IFlyable { void Fly(); }
interface IDriveable { void Drive(); }
class FlyingCar : IFlyable, IDriveable { public void Fly() {} public
void Drive() {} }
🔹 Section 8: Interfaces vs Abstract Classes – Interview
Q&A
C# OOP C# Programming Tutorial · OOP
Feature Abstract Class Interface
Implementation Can have full/partial
implementation
Cannot have full implementation (except
default methods in C# 8+)
Fields Can have fields Cannot have fields
Inheritance Single class inheritance Multiple interface inheritance allowed
Constructors Allowed Not allowed
Access
Modifiers
Can have public,
protected, private
Members are public by default
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
interface ILogger
void Log(string message);
void LogWarning(string message) => Console.WriteLine("Warning: "
+ message);
C# OOP C# Programming Tutorial · OOP
methods.
C# OOP C# Programming Tutorial · OOP
implementation.
interface ICar { int Speed { get; set; } }
abstract class Vehicle { public int Speed { get; set; } }
C# OOP C# Programming Tutorial · OOP
ICar car = new Car(); // Interface reference
// ICar c = new ICar(); // Not allowed
C# OOP C# Programming Tutorial · OOP
preferred for looser coupling.
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
interface IDriveable { void Start(); }
abstract class Vehicle { public abstract void Start(); }
class Car : Vehicle, IDriveable
public override void Start() => Console.WriteLine("Car
started");
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
default interface methods (C# 8+).
derived classes.
C# OOP C# Programming Tutorial · OOP
🔹 Section 9: Practical Scenarios & Design Questions –
Interview Q&A
C# OOP C# Programming Tutorial · OOP
interface IPlugin { void Run(); }
class PluginA : IPlugin { public void Run() =>
Console.WriteLine("Plugin A running"); }
class PluginB : IPlugin { public void Run() =>
Console.WriteLine("Plugin B running"); }
// Usage
List<IPlugin> plugins = new List<IPlugin> { new PluginA(), new
PluginB() };
foreach (var p in plugins) p.Run();
C# OOP C# Programming Tutorial · OOP
interface IPayment { void Pay(decimal amount); }
abstract class PaymentBase : IPayment
public abstract void Pay(decimal amount);
public void Log(string message) => Console.WriteLine(message);
class CreditCardPayment : PaymentBase
public override void Pay(decimal amount) =>
Console.WriteLine($"Paid {amount} by Credit Card");
C# OOP C# Programming Tutorial · OOP
abstract class Notification { public abstract void Send(string
message); }
class EmailNotification : Notification { public override void
Send(string msg) => Console.WriteLine("Email: " + msg); }
class SMSNotification : Notification { public override void
Send(string msg) => Console.WriteLine("SMS: " + msg); }
List<Notification> notifications = new List<Notification> { new
EmailNotification(), new SMSNotification() };
foreach (var n in notifications) n.Send("Hello World!");
C# OOP C# Programming Tutorial · OOP
and scalability of OOP systems.
polymorphism.
C# OOP C# Programming Tutorial · OOP
on abstractions.
interface ILogger { void Log(string message); }
class FileLogger : ILogger { public void Log(string message) =>
Console.WriteLine("File: " + message); }
class UserService
private readonly ILogger _logger;
public UserService(ILogger logger) { _logger = logger; }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
correctness.
C# OOP C# Programming Tutorial · OOP
misuse.
C# OOP C# Programming Tutorial · OOP
var mockLogger = new Mock<ILogger>();
mockLogger.Setup(x => x.Log(It.IsAny<string>()));
C# OOP C# Programming Tutorial · OOP
abstract class DataProcessor
public void Process() { ReadData(); Transform(); Save(); }
protected abstract void ReadData();
protected abstract void Transform();
protected void Save() => Console.WriteLine("Data saved");
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
interface IButton { void Render(); }
class WinButton : IButton { public void Render() =>
Console.WriteLine("Windows Button"); }
interface IGUIFactory { IButton CreateButton(); }
class WinFactory : IGUIFactory { public IButton CreateButton() =>
new WinButton(); }
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
🔹 Questions (Advanced Topics) – Interview Q&A
C# OOP C# Programming Tutorial · OOP
concept by relying on contract-based behavior.
interface IFlyable { void Fly(); }
void MakeItFly(IFlyable obj) => obj.Fly(); // Any object
implementing IFlyable works
C# OOP C# Programming Tutorial · OOP
exposing them publicly.
interface ILogger
void Log(string message) => LogInternal(message);
private void LogInternal(string msg) => Console.WriteLine(msg);
C# OOP C# Programming Tutorial · OOP
implementations.
interface IPrinter
void Print(string msg);
void PrintInfo(string msg) => Console.WriteLine("Info: " + msg);
// Default
C# OOP C# Programming Tutorial · OOP
interchangeable algorithms.
abstract class PaymentStrategy
public abstract void Pay(decimal amount);
class CreditCardPayment : PaymentStrategy
public override void Pay(decimal amount) =>
Console.WriteLine($"Paid {amount} by credit card");
C# OOP C# Programming Tutorial · OOP
necessary interfaces.
independently deployed and evolved.
autonomous service design.