Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: A blueprint or template for creating objects. Defines properties (data) and methods (behavior) that the objects will have. public class Car Example code { public string Model { get; set; } public void Start…
Short answer: An instance of a class with actual values. Represents a real-world entity in memory. Car myCar = new Car(); // Object of Car class Example code An instance of a class with actual values. Represents a real-w…
Short 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(); Real-world example (ShopNest) Think of ShopN…
Short 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 Example code { public string Model; public Car(string model) { Model =…
Short answer: A method called automatically when an object is destroyed. Used to release resources before the object is removed from memory. In C#, destructors are rarely needed due to garbage collection. ~Car() { Consol…
Short answer: The practice of hiding internal details of a class and exposing only necessary functionality through access modifiers and properties. private int speed; Example code public int Speed { get { return speed; }…
Short answer: Hiding implementation details and showing only the essential features of an object. Achieved using abstract classes and interfaces. abstract class Vehicle { Example code public abstract void Start(); } Real…
Short answer: Mechanism where a class (derived/child) inherits properties and methods from another class (base/parent). Promotes code reusability. class Car : Vehicle Example code { public override void Start() { Console…
Short 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 Real-world example (ShopNest) Ch…
Short 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 acti…
Short answer: Encapsulation is the mechanism of hiding internal details of an object and exposing only necessary functionalities. It helps in protecting data and maintaining control over how it is accessed or modified. E…
Short answer: Private → Hides data from outside access, ensuring security. Public → Provides controlled access through properties or methods. Example: private decimal balance; // hidden Example code public decimal Balanc…
Short answer: Internal → Accessible only within the same assembly. Protected → Accessible in the class and derived classes. Protected Internal → Accessible in derived classes or within the same assembly. Example code pro…
Short answer: Properties provide controlled access to private fields. Enable validation, read-only/write-only access, and future flexibility. Example: private int score; Example code public int Score { get { return score…
Short answer: Abstraction is the process of hiding the internal implementation details of a system and exposing only the essential features. It allows developers to focus on what an object does, not how it does it. Examp…
Short answer: 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 inherit…
Short answer: Reduces system complexity by focusing on essential features. Decouples modules, making large systems easier to maintain and extend. Promotes code reuse and flexibility. Real-world example (ShopNest) Checkou…
Short answer: Base Class (Parent) → Class whose members are inherited. Derived Class (Child) → Class that inherits from base class. class Vehicle { public void Start() {} } // Base Example code class Car : Vehicle {} //…
Short answer: Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable {…
Short 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: Inheritan…
Short answer: A derived class provides a new implementation of a base class method marked virtual. Achieves run-time polymorphism. class Vehicle { public virtual void Start() => Console.WriteLine("Vehicle starts&…
Short answer: virtual → Marks a base class method as overridable. override → Overrides a virtual method in the derived class. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . U…
Short answer: Prevents a class from being inherited or a method from being overridden. sealed class FinalClass { } class Car : FinalClass { } // Not allowed Real-world example (ShopNest) Think of ShopNest’s Product , Car…
Short answer: override → Overrides a virtual method in base class (runtime polymorphism). new → Hides a base class method (compile-time hiding, not true overriding). class Vehicle { public void Start() => Console.Writ…
Short answer: Base class constructor executes first, then derived class constructor. Ensures base members are initialized before derived members. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtu…
C# OOP C# Programming Tutorial · OOP
Short 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"); }
}
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short answer: An instance of a class with actual values. Represents a real-world entity in memory. Car myCar = new Car(); // Object of Car class
An instance of a class with actual values. Represents a real-world entity in memory. Car myCar = new Car(); // Object of Car class
C# OOP C# Programming Tutorial · OOP
Short 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();
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short 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");
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short answer: A method called automatically when an object is destroyed. Used to release resources before the object is removed from memory. In C#, destructors are rarely needed due to garbage collection. ~Car() { Console.WriteLine("Car object destroyed"); }
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short 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; }
}
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
C# OOP C# Programming Tutorial · OOP
Short answer: Hiding implementation details and showing only the essential features of an object. Achieved using abstract classes and interfaces. abstract class Vehicle {
public abstract void Start();
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: Mechanism where a class (derived/child) inherits properties and methods from another class (base/parent). Promotes code reusability. class Car : Vehicle
{
public override void Start() { Console.WriteLine("Car started");
}
}
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short 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
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short 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 action.
C# OOP C# Programming Tutorial · OOP
Short answer: Encapsulation is the mechanism of hiding internal details of an object and exposing only necessary functionalities. It helps in protecting data and maintaining control over how it is accessed or 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; }
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
C# OOP C# Programming Tutorial · OOP
Short answer: Private → Hides data from outside access, ensuring security. Public → Provides controlled access through properties or methods. Example: private decimal balance; // hidden
public decimal Balance { get { return balance; } } // read-only access
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
C# OOP C# Programming Tutorial · OOP
Short answer: Internal → Accessible only within the same assembly. Protected → Accessible in the class and derived classes. Protected Internal → Accessible in derived classes or within the same assembly.
protected string accountType; // accessible in derived classes internal string branchCode; // accessible within same assembly
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short answer: Properties provide controlled access to private fields. Enable validation, read-only/write-only access, and future flexibility. Example: private int score;
public int Score
{ get { return score; } set { if (value >= 0) score = value; } // validation
}
ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.
C# OOP C# Programming Tutorial · OOP
Short answer: Abstraction is the process of hiding the internal implementation details of a system and exposing only the essential features. It allows developers to focus on what an object does, not how it does it.
A Vehicle class exposes Start() method without revealing engine details.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short answer: 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
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Reduces system complexity by focusing on essential features. Decouples modules, making large systems easier to maintain and extend. Promotes code reuse and flexibility.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
C# OOP C# Programming Tutorial · OOP
Short 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
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); } interface IDriveable { void Drive(); } class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} }
Use interfaces to achieve multiple inheritance. A class can implement multiple interfaces. interface IFlyable { void Fly(); }
interface IDriveable { void Drive(); }
class FlyingCar : IFlyable, IDriveable { public void Fly() {} public void Drive() {} }
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short 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
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: A derived class provides a new implementation of a base class method marked virtual. Achieves run-time polymorphism. class Vehicle { public virtual void Start() => Console.WriteLine("Vehicle starts"); } class Car : Vehicle { public override void Start() => Console.WriteLine("Car starts"); }
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short answer: virtual → Marks a base class method as overridable. override → Overrides a virtual method in the derived class.
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Prevents a class from being inherited or a method from being overridden. sealed class FinalClass { } class Car : FinalClass { } // Not allowed
Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.
C# OOP C# Programming Tutorial · OOP
Short answer: override → Overrides a virtual method in base class (runtime polymorphism). new → Hides a base class method (compile-time hiding, not true overriding). class Vehicle { public void Start() => Console.WriteLine("Vehicle");
}
class Car : Vehicle { public new void Start() => Console.WriteLine("Car"); }
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.
C# OOP C# Programming Tutorial · OOP
Short answer: Base class constructor executes first, then derived class constructor. Ensures base members are initialized before derived members.
ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.