Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
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…
Short 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. Real-world example (Sho…
Short answer: Also called static polymorphism. Resolved at compile time. Achieved through method overloading or operator overloading. class Calculator Example code { public int Add(int a, int b) => a + b; public doubl…
Short answer: Also called dynamic polymorphism. Resolved at runtime using method overriding. class Vehicle { public virtual void Start() => Console.WriteLine("Vehicle starts"); } class Car : Vehicle { public…
Short answer: Same method name with different parameters in the same class. Enables compile-time polymorphism. class MathHelper Example code { public int Multiply(int a, int b) => a * b; public int Multiply(int a, int…
Short answer: Defining custom behavior for operators (+, -, *, etc.) for a class. class Point Example code { public int X, Y; public static Point operator +(Point a, Point b) => new Point { X = a.X + b.X, Y = a.Y + b.…
Short 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 Real-world ex…
Short answer: Early binding → Resolved at compile time (e.g., method overloading). Late binding → Resolved at runtime (e.g., method overriding with virtual/override). Say this in the interview Define — one clear sentence…
Short 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(); Example code object is the base class for all C# types. Enables poly…
Short answer: Interfaces allow different classes to implement the same contract, enabling dynamic behavior at runtime. interface IDriveable { void Drive(); } class Car : IDriveable { public void Drive() => Console.Wri…
Short answer: Another term for runtime polymorphism, achieved via method overriding. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same interface, so S…
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.
C# OOP C# Programming Tutorial · OOP
Short 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.
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: Also called static polymorphism. Resolved at compile time. Achieved through method overloading or operator overloading. class Calculator
{
public int Add(int a, int b) => a + b;
public double Add(double a, double b) => a + b; // Overloaded method }
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: Also called dynamic polymorphism. Resolved at runtime using method overriding. 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
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: 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 }
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: 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 };
}
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: Feature Overloading Overriding Compile/Runtime Compile-time Runtime Same signature? No, different parameters Same signature Virtual required? No Yes Inheritance required? Not required Required
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: Early binding → Resolved at compile time (e.g., method overloading). Late binding → Resolved at runtime (e.g., method overriding with virtual/override).
C# OOP C# Programming Tutorial · OOP
Short 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();
object is the base class for all C# types. Enables polymorphism, as any object can be referred using object type. object obj = new Car();
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: Interfaces allow different classes to implement the same contract, enabling 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"); }
Interfaces allow different classes to implement the same contract, enabling 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"); }
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: Another term for runtime polymorphism, achieved via method overriding.
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.