Technical interview Q&A plus 100+ career & HR questions—notice period, salary negotiation, resume, LinkedIn, freelancing, AI careers, and behavioral interviews with detailed, real-world answers.
C# OOP C# Programming Tutorial · OOP
functionality.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: OOP is a programming paradigm that organizes software around objects, which contain data (fields/properties) and behavior (methods/functions). Helps model real-world entities and their interactions.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Promotes code reusability through classes and objects. Easier to maintain and extend large applications. Models real-world problems better. Supports modularity, abstraction, and encapsulation, which procedural programming lacks.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: class Vehicle {} // Base class Car : Vehicle {} // Single/Multilevel class Bike : Vehicle {} // Hierarchical
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
overloading/overriding).
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
C# OOP C# Programming Tutorial · OOP
Answer: A blueprint or template for creating objects. Defines properties (data) and methods (behavior) that the objects will have. public class Car { public string Model { get; set; } public void Start() { Console.WriteLine("Car started"); } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: An instance of a class with actual values. Represents a real-world entity in memory. Car myCar = new Car(); // Object of Car class
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Feature Class Object Definition Blueprint/Template Instance of a class Memory Does not occupy memory Occupies memory Example class Car { } Car myCar = new Car();
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: A special method used to initialize objects when they are created. Has the same name as the class and no return type. public class Car { public string Model; public Car(string model) { Model = model; } } Car car = new Car("Tesla");
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
~Car() { Console.WriteLine("Car object destroyed"); }
C# OOP C# Programming Tutorial · OOP
Answer: Instance members → Belong to each object, require object to access. Static members → Belong to the class itself, shared by all objects. public class Car { public string Model; // Instance public static int Count; // Static }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: The practice of hiding internal details of a class and exposing only necessary functionality through access modifiers and properties. private int speed; public int Speed { get { return speed; } set { speed = value; } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Hiding implementation details and showing only the essential features of an object. Achieved using abstract classes and interfaces. bstract class Vehicle { public abstract void Start(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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 VehicleC# OOP C# Programming Tutorial · OOP
Answer: Ability of an object to take multiple forms. Types: Compile-time (method overloading) Run-time (method overriding) Vehicle v = new Car(); v.Start(); // Run-time polymorphism
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Car object: Class → Car Objects → myCar, yourCar Properties → Color, Model, Speed Methods → Start(), Stop(), Accelerate() Shows encapsulation, inheritance (e.g., ElectricCar : Car), and polymorphism in ction.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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 +=
mount; }
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
ccess
C# OOP C# Programming Tutorial · OOP
Example:
protected string accountType; // accessible in derived classes
internal string branchCode; // accessible within same assemblyC# OOP C# Programming Tutorial · OOP
Answer: Technically yes, but not recommended. Makes the data vulnerable to invalid modifications. Encapsulation recommends private fields + public properties.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Encapsulation → Hides internal data, focuses on data protection. Abstraction → Hides implementation details, focuses on simplifying complex systems.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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)
{
ccountNumber = accNum;
balance = initialBalance >= 0 ? initialBalance : throw new
rgumentException("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:
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
Answer: Simplifies complex systems by exposing only relevant functionality. Enhances maintainability, readability, and reusability of code. Reduces dependency on implementation details, making systems more flexible.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Using abstract classes or interfaces. Abstract classes can have abstract and non-abstract methods. Interfaces define method signatures only. bstract class Vehicle { public abstract void Start(); } interface IDriveable { void Drive(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
(without implementation).
bstract class Animal
{
public abstract void MakeSound();
public void Sleep() => Console.WriteLine("Sleeping");
}C# OOP C# Programming Tutorial · OOP
Answer: Interfaces define a contract of methods, properties, or events that implementing classes must follow. Interfaces provide full abstraction without any implementation (C# 8+ allows default methods). interface IFlyable { void Fly(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
nd 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
bstract 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
Answer: Yes, constructors are used to initialize fields in derived classes. bstract class Vehicle { protected string Brand; public Vehicle(string brand) { Brand = brand; } } class Car : Vehicle { public Car(string brand) : base(brand) { } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, abstract classes can have concrete methods with implementation. Allows shared behavior for derived classes. bstract class Animal { public void Sleep() => Console.WriteLine("Sleeping"); public abstract void MakeSound(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Reduces system complexity by focusing on essential features. Decouples modules, making large systems easier to maintain and extend. Promotes code reuse and flexibility.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Hides implementation details, exposing only what is necessary. Users interact with interfaces or abstract methods, not the full system logic. Simplifies testing, maintenance, and understanding of code.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Real-World Example: Payment Processing
// Abstract class
bstract 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.
C# OOP C# Programming Tutorial · OOP
Answer: Base Class (Parent) → Class whose members are inherited. Derived Class (Child) → Class that inherits from base class. class Vehicle { public void Start() {} } // Base class Car : Vehicle {} // Derived
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
No, C# does not support multiple class inheritance to avoid ambiguity.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Feature Inheritance Composition Relationship "is-a" "has-a" Reuse Derived class reuses base class Object contains other objects Flexibility Less flexible More flexible Example: Inheritance → Car is a Vehicle Composition → Car has a Engine
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: virtual → Marks a base class method as overridable. override → Overrides a virtual method in the derived class.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Prevents a class from being inherited or a method from being overridden. sealed class FinalClass { } class Car : FinalClass { } // Not allowed
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Common functionality is implemented in base class. Derived classes reuse the code without duplicating it, reducing maintenance effort.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Base class constructor executes first, then derived class constructor. Ensures base members are initialized before derived members.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: No, private members are hidden from derived classes. Can access protected, internal, or public members. class Vehicle { private int id; protected string model; } class Car : Vehicle { /* cannot access id, can access model */ }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Polymorphism means “many forms”. It allows objects of different types to be treated as objects of a common base type. Achieved through method overloading, overriding, and interfaces.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Same method name with different parameters in the same class. Enables compile-time polymorphism. class MathHelper { public int Multiply(int a, int b) => a * b; public int Multiply(int a, int b, int c) => a * b * c; // Overloaded }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, constructors can have multiple signatures in the same class. class Car { public Car() { } public Car(string model) { } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: No, constructors cannot be inherited or overridden. Base class constructor can be called using : base(), but cannot be overridden.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Defining custom behavior for operators (+, -, *, etc.) for a class. 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 }; }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Feature Overloading Overriding Compile/Runtime Compile-time Runtime Same signature? No, different parameters Same signature Virtual required? No Yes Inheritance required? Not required Required
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Early binding → Resolved at compile time (e.g., method overloading). Late binding → Resolved at runtime (e.g., method overriding with virtual/override).
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: object is the base class for all C# types. Enables polymorphism, as any object can be referred using object type. object obj = new Car();
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Through:
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Another term for runtime polymorphism, achieved via method overriding.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Code depends on interfaces or base classes, not concrete implementations. Makes system flexible, extendable, and easier to maintain. void StartVehicle(Vehicle v) { v.Start(); } // Works with any derived type
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Advantages: Promotes code reuse and flexibility Enables loose coupling Supports extensible architecture Disadvantages: May introduce runtime overhead Can make code harder to understand if overused Requires careful design to avoid ambiguity
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: An interface is a contract that defines method signatures, properties, events, or indexers without providing implementation. Classes or structs that implement the interface must provide the implementation.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Use the interface keyword. interface IDriveable { void Drive(); int Speed { get; set; } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Use the colon (:) symbol and implement all members. class Car : IDriveable { public int Speed { get; set; } public void Drive() => Console.WriteLine("Car is driving"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: No, interfaces cannot have fields. Only methods, properties, events, or indexers.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
No, interfaces cannot have constructors.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, starting from C# 8, interfaces can contain static methods. interface IUtility { static void Show() => Console.WriteLine("Static method in interface"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, methods can have default implementations in interfaces. interface ILogger { void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning: " + message); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Yes, a class can implement multiple interfaces, solving multiple inheritance issues. class FlyingCar : IDriveable, IFlyable { public void Drive() => Console.WriteLine("Driving"); public void Fly() => Console.WriteLine("Flying"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: The implementing class must provide a single implementation for both interfaces. Or use explicit interface implementation to differentiate.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, explicit implementation allows a class to implement interface members separately. class Car : IDriveable { void IDriveable.Drive() => Console.WriteLine("Explicit drive"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Implementing an interface member explicitly so it can only be called via interface reference, not class object. IDriveable car = new Car(); car.Drive(); // Works // Car c = new Car(); c.Drive(); // Won't compile
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Define contracts for classes. Achieve abstraction, polymorphism, and loose coupling.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Expose method signatures without implementation. Users interact with the interface, not the underlying implementation.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Code depends on interface, not concrete class. Makes it easier to swap implementations without changing dependent code. void StartVehicle(IDriveable vehicle) { vehicle.Drive(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Provides a standard method to compare objects for sorting. class Employee : IComparable<Employee> { public int Id { get; set; } public int CompareTo(Employee other) => this.Id.CompareTo(other.Id); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Provides Dispose() method for releasing unmanaged resources. class FileHandler : IDisposable { public void Dispose() => Console.WriteLine("Resources released"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: IEnumerable → Provides collection traversal capability (GetEnumerator() method). IEnumerator → Used to iterate over a collection (MoveNext(), Current, Reset()).
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, interfaces can inherit from other interfaces, forming a hierarchy. interface IFlyable { void Fly(); } interface IAdvancedFlyable : IFlyable { void Loop(); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Interfaces with no methods or properties, used to mark classes for special behavior. Example: ISerializable marks classes as serializable.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: An abstract class is a class that cannot be instantiated directly. Can contain abstract methods (without implementation) and concrete methods (with implementation). Used to define a common base for other classes.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Use the abstract keyword. bstract class Vehicle { public abstract void Start(); public void Stop() => Console.WriteLine("Vehicle stopped"); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
bstract class Vehicle
{
public abstract void Start();
}
class Car : Vehicle
{
public override void Start() => Console.WriteLine("Car
started");
}C# OOP C# Programming Tutorial · OOP
Answer: Yes, abstract classes can have fields, properties, and constants. bstract class Vehicle { protected string Brand; }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
interface IDriveable { void Drive(); }
bstract class Vehicle : IDriveable { public abstract void Drive();
}
class Car : Vehicle { public override void Drive() =>
Console.WriteLine("Car drives"); }
C# OOP C# Programming Tutorial · OOP
Answer: No, abstract classes cannot be sealed. A sealed class cannot be inherited, while abstract classes are meant to be inherited.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, abstract classes can have private members, but derived classes cannot ccess them. Private members can be accessed via protected or public methods.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: No, a class cannot be both abstract and static. Abstract classes are for inheritance, static classes cannot be inherited.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
llow derived class to optionally override
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Abstract classes can provide shared implementation, fields, and constructors. Useful when multiple classes share common behavior along with enforced bstraction.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
bstract 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
pplication");
}
// Usage
Employee dev = new Developer() { Name = "Alice" };
dev.Work();
dev.Report();
C# OOP C# Programming Tutorial · OOP
Answer: 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
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
subclasses.
bstract 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() {} }
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
ccess
Modifiers
Can have public,
protected, private
Members are public by default
C# OOP C# Programming Tutorial · OOP
Answer: When you want to define pure contracts without implementation. When you need multiple inheritance. When you want loose coupling for dependency injection.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: When you want to share common code among related classes. When you need fields or constructors. When future changes may require adding non-breaking methods.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: bstract classes? Yes → Multiple interfaces No → Multiple abstract classes (C# does not support multiple class inheritance)
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Interface allows multiple inheritance.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, starting from C# 8, interfaces can have default method implementations. interface ILogger { void Log(string message); void LogWarning(string message) => Console.WriteLine("Warning: " + message); }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, abstract classes can have fully implemented methods along with abstract methods.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, both can define properties. Interface properties are abstract by default; abstract class properties can have implementation. interface ICar { int Speed { get; set; } } bstract class Vehicle { public int Speed { get; set; } }
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: No, you cannot instantiate an interface. You can only use it as a reference type. ICar car = new Car(); // Interface reference // ICar c = new ICar(); // Not allowed
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, abstract classes can be injected as service contracts, but interfaces are preferred for looser coupling.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Both can define contracts for derived classes. Both support polymorphism. Both cannot be instantiated directly. Both can be used with dependency injection.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Interface contracts are pure method signatures. Abstract class contracts can contain shared code and fields.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
interface IDriveable { void Start(); }
bstract class Vehicle { public abstract void Start(); }
class Car : Vehicle, IDriveable
{
public override void Start() => Console.WriteLine("Car
started");
}C# OOP C# Programming Tutorial · OOP
No, interfaces can only inherit other interfaces.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Yes, abstract classes can implement interfaces partially or fully.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: bstract classes? Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in most applications.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Abstract classes are slightly faster because they use direct method calls. Interfaces may incur slight overhead due to indirect method calls via vtable. Difference is usually negligible in most applications.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Interfaces are preferred for public APIs because they: Allow multiple inheritance Support loose coupling Avoid breaking changes when adding new implementations Abstract classes are better for internal APIs where shared code is required.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Interfaces: Adding new members breaks existing implementations unless using default interface methods (C# 8+). Abstract Classes: Can add new methods with implementation without breaking derived classes.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
nd interfaces?
interface IPayment { void Pay(decimal amount); }
bstract 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
bstract 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
Answer: SOLID principles are design guidelines that enhance maintainability, flexibility, nd scalability of OOP systems. They guide proper use of abstraction, inheritance, encapsulation, and polymorphism.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Protects internal data by restricting direct access. Ensures sensitive fields are accessed only via methods/properties, preventing misuse.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Use mocking frameworks like Moq or NSubstitute. Provides fake implementations to test dependent classes. var mockLogger = new Mock<ILogger>(); mockLogger.Setup(x => x.Log(It.IsAny<string>()));
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
bstract 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
Answer: When behavior varies significantly. When tight coupling or fragile base class problem may occur.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Hard to maintain and understand. Fragile base class problem. Overridden behavior may break subclasses.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Provides flexibility, reduces tight coupling, and avoids deep hierarchies.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Minor runtime overhead for virtual calls. Usually negligible; design benefits outweigh performance cost.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Use new interface or default implementations (C# 8+). Avoid modifying existing interface to maintain backward compatibility.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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
Answer: Base abstract class Shape with Draw() method. Derived classes like Circle, Rectangle override Draw(). Supports polymorphic behavior.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Define abstract class FileHandler with method Read(). Derived classes CsvHandler, XmlHandler implement Read(). Use base class reference to process files uniformly.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: When you want to share code or fields across derived classes. When common behavior is needed along with enforced methods.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Use composition or explicit interface implementation to avoid ambiguity.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Deep hierarchies, fragile base classes, tight coupling, misuse of override.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, adding new members can break existing implementations. Use default interface methods to avoid breaking changes.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Allows dependency injection of mocks/stubs. Enables unit testing without relying on concrete implementations.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Virtual calls resolved at runtime. Minor overhead due to vtable lookups, generally negligible.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
C# OOP C# Programming Tutorial · OOP
Answer: Yes, interfaces can define event contracts for publishers/subscribers. Enables decoupling of event producers and consumers.
In a production C# OOP application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
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.
bstract 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.
utonomous service design.