Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4608 total questions 4508 technical 100 career & HR 4272 from PDF library

Showing 1301–1325 of 4608

Career & HR topics

By tech stack

Popular tracks

Mid PDF
How does versioning work differently for interfaces and abstract classes?

Short 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. Exa…

Mid PDF
Which supports multiple inheritance in C#?

Short answer: Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A Example code Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A Real-world example (ShopN…

Mid PDF
How would you design a plugin system using interfaces?

Short answer: Define an interface like IPlugin with a Run() method. Explain a bit more Each plugin implements IPlugin and can be loaded dynamically. interface IPlugin { void Run(); } class PluginA : IPlugin { public void…

Mid PDF
How would you design a payment system using abstract classes

Short answer: And interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } bstract class PaymentBase : IPaymen…

Mid PDF
How would you design a payment system using abstract classes and interfaces?

Short answer: Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } abstract class PaymentBase : IPayment { Example cod…

Mid PDF
How can you implement a notification system using polymorphism?

Short answer: Define a base Notification class or interface. Derive classes like EmailNotification, SMSNotification. abstract class Notification { public abstract void Send(string message); } class EmailNotification : No…

Senior PDF
How does the SOLID principle relate to OOP?

Short answer: SOLID principles are design guidelines that enhance maintainability, flexibility, and scalability of OOP systems. They guide proper use of abstraction, inheritance, encapsulation, and polymorphism. Real-wor…

Junior PDF
What is the Dependency Inversion Principle and how do interfaces support it?

Short answer: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); } Example code cl…

Junior PDF
What is the Liskov Substitution Principle and how does inheritance

Short answer: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a…

Junior PDF
What is the Liskov Substitution Principle and how does inheritance affect it?

Short answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior. Real-world example (ShopNest) ShopNest has a base Payme…

Mid PDF
What’s the role of encapsulation in API security?

Short answer: Protects internal data by restricting direct access. Ensures sensitive fields are accessed only via methods/properties, preventing misuse. Real-world example (ShopNest) ShopNest’s Order keeps _items private…

Mid PDF
How do you mock interfaces in unit testing?

Short 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>()))…

Mid PDF
How do abstract classes help in enforcing a template method pattern?

Short answer: Abstract class defines skeleton of algorithm. Derived classes override steps without changing algorithm structure. abstract class DataProcessor { Example code public void Process() { ReadData(); Transform()…

Mid PDF
In what situations should you avoid inheritance?

Short answer: When behavior varies significantly. When tight coupling or fragile base class problem may occur. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and C…

Mid PDF
What are the risks of deep inheritance hierarchies?

Short answer: Hard to maintain and understand. Fragile base class problem. Overridden behavior may break subclasses. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment…

Mid PDF
Why is composition preferred over inheritance in some cases?

Short answer: Provides flexibility, reduces tight coupling, and avoids deep hierarchies. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override th…

Mid PDF
Can polymorphism lead to performance issues?

Short answer: Minor runtime overhead for virtual calls. Usually negligible; design benefits outweigh performance cost. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters…

Mid PDF
How do you handle versioning when using interfaces?

Short answer: Use new interface or default implementations (C# 8+). Avoid modifying existing interface to maintain backward compatibility. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay…

Mid PDF
How would you design a shape hierarchy using OOP?

Short answer: Base abstract class Shape with Draw() method. Derived classes like Circle, Rectangle override Draw(). Supports polymorphic behavior. Real-world example (ShopNest) Think of ShopNest’s Product , Cart , and Or…

Mid PDF
How would you use polymorphism to handle different file formats?

Short answer: Define abstract class FileHandler with method Read(). Derived classes CsvHandler, XmlHandler implement Read(). Use base class reference to process files uniformly. Real-world example (ShopNest) Checkout cal…

Mid PDF
When is it better to use a base class instead of interfaces?

Short answer: When you want to share code or fields across derived classes. When common behavior is needed along with enforced methods. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal…

Mid PDF
How would you refactor code with multiple interface implementations?

Short answer: Use composition or explicit interface implementation to avoid ambiguity. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adapters implement the same interface, so…

Mid PDF
What are common pitfalls when using inheritance?

Short answer: Deep hierarchies, fragile base classes, tight coupling, misuse of override. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and CardPayment override t…

Mid PDF
Can interface changes break backward compatibility?

Short answer: Yes, adding new members can break existing implementations. Use default interface methods to avoid breaking changes. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stri…

Mid PDF
How does using abstract classes or interfaces help in testability?

Short answer: Allows dependency injection of mocks/stubs. Enables unit testing without relying on concrete implementations. Real-world example (ShopNest) Checkout calls IPaymentGateway.Charge() . Razorpay and Stripe adap…

C# OOP C# Programming Tutorial · OOP

Short 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.

Example code

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.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A

Example code

Interfaces support multiple inheritance. Abstract classes do not. Interview Q&A

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Define an interface like IPlugin with a Run() method.

Explain a bit more

Each plugin implements IPlugin and can be loaded dynamically. 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();

Example code

Define an interface like IPlugin with a Run() method. Each plugin implements IPlugin and can be loaded dynamically. 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();

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: And interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. 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 {……… nd interfaces? nd interfaces? Use an interface for common…

Explain a bit more

operations: IPayment. Use an abstract class for shared behavior like logging. 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 {… nd interfaces? Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. 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… And… public abstract void Pay(decimal amount);

Example code

public void Log(string message) => Console.WriteLine(message);
}
class CreditCardPayment : PaymentBase
{
public override void Pay(decimal amount) => Console.WriteLine($"Paid {amount} by Credit Card"); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Use an interface for common operations: IPayment. Use an abstract class for shared behavior like logging. interface IPayment { void Pay(decimal amount); } abstract class PaymentBase : IPayment {

Example code

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"); }

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Define a base Notification class or interface. Derive classes like EmailNotification, SMSNotification. abstract class Notification { public abstract void Send(string message); } class EmailNotification : Notification { public override void

Example code

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!");

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: SOLID principles are design guidelines that enhance maintainability, flexibility, and scalability of OOP systems. They guide proper use of abstraction, inheritance, encapsulation, and polymorphism.

Real-world example (ShopNest)

ShopNest splits “save order” and “send email” into different services (SRP). The order service depends on IEmailSender (DIP), so unit tests can fake email.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: High-level modules should not depend on low-level modules. Both should depend on abstractions. Interfaces allow decoupling and easier testing. interface ILogger { void Log(string message); }

Example code

class FileLogger : ILogger { public void Log(string message) => Console.WriteLine("File: " + message); } class UserService
{
private readonly ILogger _logger;
public UserService(ILogger logger) { _logger = logger; }
}

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: ffect it? Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Derived classes should be replaceable by base class without affecting correctness. Inheritance violating this principle can cause unexpected behavior.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Protects internal data by restricting direct access. Ensures sensitive fields are accessed only via methods/properties, preventing misuse.

Real-world example (ShopNest)

ShopNest’s Order keeps _items private and exposes AddItem() so totals stay correct—callers cannot put a negative quantity directly into the list.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short 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>()));

Example code

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>()));

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Abstract class defines skeleton of algorithm. Derived classes override steps without changing algorithm structure. abstract class DataProcessor {

Example code

public void Process() { ReadData(); Transform(); Save(); } protected abstract void ReadData(); protected abstract void Transform(); protected void Save() => Console.WriteLine("Data saved");
}

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: When behavior varies significantly. When tight coupling or fragile base class problem may occur.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Hard to maintain and understand. Fragile base class problem. Overridden behavior may break subclasses.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Provides flexibility, reduces tight coupling, and avoids deep hierarchies.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Minor runtime overhead for virtual calls. Usually negligible; design benefits outweigh performance cost.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Use new interface or default implementations (C# 8+). Avoid modifying existing interface to maintain backward compatibility.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Base abstract class Shape with Draw() method. Derived classes like Circle, Rectangle override Draw(). Supports polymorphic behavior.

Real-world example (ShopNest)

Think of ShopNest’s Product, Cart, and Order classes: each object holds data + behavior, so pricing rules stay next to the data they use.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Define abstract class FileHandler with method Read(). Derived classes CsvHandler, XmlHandler implement Read(). Use base class reference to process files uniformly.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: When you want to share code or fields across derived classes. When common behavior is needed along with enforced methods.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Use composition or explicit interface implementation to avoid ambiguity.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Deep hierarchies, fragile base classes, tight coupling, misuse of override.

Real-world example (ShopNest)

ShopNest has a base PaymentMethod with virtual decimal Fee(). UpiPayment and CardPayment override the fee logic without changing the checkout caller.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Yes, adding new members can break existing implementations. Use default interface methods to avoid breaking changes.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share

C# OOP C# Programming Tutorial · OOP

Short answer: Allows dependency injection of mocks/stubs. Enables unit testing without relying on concrete implementations.

Real-world example (ShopNest)

Checkout calls IPaymentGateway.Charge(). Razorpay and Stripe adapters implement the same interface, so ShopNest can switch gateways without rewriting the order service.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details