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 301–325 of 398

Career & HR topics

By tech stack

Mid PDF
What are the characteristics of a good unit test?

Short answer: A good unit test is: Isolated: Tests one unit without external dependencies. Repeatable: Produces the same results every run. Fast: Executes quickly to allow frequent runs. Automated: Runs without manual in…

Testing Read answer
Mid PDF
How do you decide what to test in your application?

Short answer: Focus on testing: Critical business logic. Edge cases and boundary conditions. Public methods and APIs. Error handling and exception paths. Code that is prone to bugs or complex. Real-world example (ShopNes…

Testing Read answer
Mid PDF
What are the challenges of writing unit tests?

Short answer: Challenges include: Managing external dependencies and state. Writing tests for legacy or tightly coupled code. Maintaining tests as code evolves. Ensuring tests are meaningful and not brittle. Balancing te…

Testing Read answer
Mid PDF
How do you handle dependencies in unit testing?

Short answer: Use mocking or stubbing frameworks (e.g., Moq, NSubstitute) to replace real dependencies with controlled test doubles, allowing tests to focus on the unit under test. Say this in the interview Define — one…

Testing Read answer
Mid PDF
What are the benefits of automated unit testing?

Short answer: Fast feedback on code changes. Detect regressions early. Supports continuous integration and delivery. Improves code quality and confidence. Enables safer refactoring. Real-world example (ShopNest) ShopNest…

Testing Read answer
Mid PDF
How do you run unit tests in Visual Studio?

Short answer: Use Test Explorer to discover and run tests. Tests can be run individually or in bulk. Use keyboard shortcuts (e.g., Ctrl+R, A to run all tests). Integrate with CI pipelines for automated test runs. Say thi…

Testing Read answer
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…

Mid PDF
How does runtime type checking affect abstract/interface-based polymorphism?

Short answer: Virtual calls resolved at runtime. Minor overhead due to vtable lookups, generally negligible. Real-world example (ShopNest) ShopNest has a base PaymentMethod with virtual decimal Fee() . UpiPayment and Car…

Mid PDF
Can interfaces have private methods (C# 8+)?

Short answer: If so, why? Yes, C# 8 introduced private methods in interfaces. Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) =&g…

Mid PDF
Can interfaces have private methods (C# 8+)? If so, why?

Short answer: Yes, C# 8 introduced private methods in interfaces. Explain a bit more Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string messa…

Mid PDF
How do abstract classes relate to abstract factories or strategy patterns?

Short answer: Abstract classes often define base contracts or template methods for patterns: Abstract Factory: Defines abstract methods to create families of objects. Strategy Pattern: Abstract class defines a common int…

Mid PDF
How does OOP enable microservice isolation and autonomy?

Short answer: Encapsulation and abstraction hide implementation details, exposing only necessary interfaces. Polymorphism allows replaceable modules, facilitating microservices independently deployed and evolved. SOLID p…

Unit Testing C# Programming Tutorial · Testing

Short answer: A good unit test is: Isolated: Tests one unit without external dependencies. Repeatable: Produces the same results every run. Fast: Executes quickly to allow frequent runs. Automated: Runs without manual intervention. Clear: Easy to understand and maintain. Independent: Does not depend on other tests.

Real-world example (ShopNest)

Arrange a cart with 2 items → Act Checkout() → Assert total and that payment was called once.

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

Unit Testing C# Programming Tutorial · Testing

Short answer: Focus on testing: Critical business logic. Edge cases and boundary conditions. Public methods and APIs. Error handling and exception paths. Code that is prone to bugs or complex.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

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

Unit Testing C# Programming Tutorial · Testing

Short answer: Challenges include: Managing external dependencies and state. Writing tests for legacy or tightly coupled code. Maintaining tests as code evolves. Ensuring tests are meaningful and not brittle. Balancing test coverage and development speed.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

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

Unit Testing C# Programming Tutorial · Testing

Short answer: Use mocking or stubbing frameworks (e.g., Moq, NSubstitute) to replace real dependencies with controlled test doubles, allowing tests to focus on the unit under test.

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

Unit Testing C# Programming Tutorial · Testing

Short answer: Fast feedback on code changes. Detect regressions early. Supports continuous integration and delivery. Improves code quality and confidence. Enables safer refactoring.

Real-world example (ShopNest)

ShopNest unit tests cover pricing and discount rules so a bad coupon change fails in CI before customers see it.

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

Unit Testing C# Programming Tutorial · Testing

Short answer: Use Test Explorer to discover and run tests. Tests can be run individually or in bulk. Use keyboard shortcuts (e.g., Ctrl+R, A to run all tests). Integrate with CI pipelines for automated test runs.

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

C# OOP C# Programming Tutorial · OOP

Short answer: Virtual calls resolved at runtime. Minor overhead due to vtable lookups, generally negligible.

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: If so, why? Yes, C# 8 introduced private methods in interfaces. Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) => LogInternal(message); private void LogInternal(string msg) => Console.WriteLine(msg); }

Example code

If so, why? Yes, C# 8 introduced private methods in interfaces. Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger
{
void Log(string message) => LogInternal(message);
private void LogInternal(string msg) => Console.WriteLine(msg);
}

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: Yes, C# 8 introduced private methods in interfaces.

Explain a bit more

Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) => LogInternal(message); private void LogInternal(string msg) => Console.WriteLine(msg); } Yes, C# 8 introduced private methods in interfaces. Purpose: share implementation among default interface methods without exposing them publicly. interface ILogger { void Log(string message) => LogInternal(message); private void LogInternal(string msg) => Console.WriteLine(msg);

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: Abstract classes often define base contracts or template methods for patterns: Abstract Factory: Defines abstract methods to create families of objects. Strategy Pattern: Abstract class defines a common interface for interchangeable algorithms. abstract class PaymentStrategy {

Example code

public abstract void Pay(decimal amount);
}
class CreditCardPayment : PaymentStrategy
{
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: Encapsulation and abstraction hide implementation details, exposing only necessary interfaces. Polymorphism allows replaceable modules, facilitating microservices independently deployed and evolved. SOLID principles and interface-based contracts promote loose coupling and autonomous service design.

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