Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Common functionality is implemented in base class. Derived classes reuse the code without duplicating it, reducing maintenance effort. Real-world example (ShopNest) ShopNest has a base PaymentMethod with vi…
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: No, private members are hidden from derived classes. Can access protected, internal, or public members. class Vehicle { private int id; protected string model; } Example code class Car : Vehicle { /* cannot…
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: Yes, constructors can have multiple signatures in the same class. class Car Example code { public Car() { } public Car(string model) { } } Real-world example (ShopNest) Think of ShopNest’s Product , Cart ,…
Short answer: No, constructors cannot be inherited or overridden. Base class constructor can be called using : base(), but cannot be overridden. Real-world example (ShopNest) Think of ShopNest’s Product , Cart , and Orde…
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: How is polymorphism implemented in C#? is a common interview topic in C# OOP. Give a clear definition, then one concrete example. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razo…
Short answer: abstract class Shape { public abstract void Draw(); } class Circle : Shape { public override void Draw() => Console.WriteLine("Drawing Circle"); } class Rectangle : Shape { public override void…
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…
Short 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 typ…
Short 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…
Short 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.…
Short answer: Use the interface keyword. interface IDriveable Example code { void Drive(); int Speed { get; set; } } Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters im…
Short answer: Use the colon (:) symbol and implement all members. class Car : IDriveable Example code { public int Speed { get; set; } public void Drive() => Console.WriteLine("Car is driving"); } Real-world…
Short answer: No, interfaces cannot have fields. Only methods, properties, events, or indexers. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same inte…
Short answer: No, interfaces cannot have constructors. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways wi…
Short answer: Yes, starting from C# 8, interfaces can contain static methods. interface IUtility Example code { static void Show() => Console.WriteLine("Static method in interface"); } Real-world example (Sh…
C# OOP C# Programming Tutorial · OOP
Short answer: Common functionality is implemented in base class. Derived classes reuse the code without duplicating it, reducing maintenance effort.
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: 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 */ }
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: Yes, constructors can have multiple signatures in the same class. class Car
{
public Car() { }
public Car(string model) { }
}
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: No, constructors cannot be inherited or overridden. Base class constructor can be called using : base(), but cannot be overridden.
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: How is polymorphism implemented in C#? is a common interview topic in C# OOP. Give a clear definition, then one concrete example.
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: 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
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.
C# OOP C# Programming Tutorial · OOP
Short 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
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: 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
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: 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.
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: Use the interface keyword. interface IDriveable
{ void Drive(); int Speed { get; set; }
}
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: Use the colon (:) symbol and implement all members. class Car : IDriveable
{
public int Speed { get; set; }
public void Drive() => Console.WriteLine("Car is driving");
}
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: No, interfaces cannot have fields. Only methods, properties, events, or indexers.
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: No, interfaces cannot have constructors.
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: Yes, starting from C# 8, interfaces can contain static methods. interface IUtility
{ static void Show() => Console.WriteLine("Static method in interface");
}
Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.