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 1401–1425 of 4608

Career & HR topics

By tech stack

Popular tracks

Mid PDF
What are real-world examples of Strategy pattern usage?

Short answer: Payment gateways (Credit Card, PayPal, UPI, etc.) Sorting algorithms (QuickSort, MergeSort, BubbleSort) Authentication strategies (OAuth, JWT, LDAP) Compression algorithms (ZIP, RAR, TAR) Loggers (FileLogge…

SOLID Read answer
Mid PDF
How does the Strategy pattern promote Open/Closed Principle?

Short answer: It promotes the Open/Closed Principle by allowing you to add new strategies (algorithms or behaviors) without modifying the existing code. The context class uses an interface for the strategy, so new behavi…

SOLID Read answer
Mid PDF
How does Strategy pattern differ from State pattern?

Short answer: Aspect Strategy Pattern State Pattern Purpose Encapsulates interchangeable behaviors (algorithms). Explain a bit more Encapsulates states and transitions between them. Client Control Client decides which st…

SOLID Read answer
Junior PDF
What is the Repository pattern and why is it important in .NET

Short answer: Applications? The Repository pattern abstracts the data access layer from the business logic by providing collection-like interface to access domain objects. It helps keep data access logic centralized and…

SOLID Read answer
Junior PDF
What is the Repository pattern and why is it important in .NET applications?

Short answer: The Repository pattern abstracts the data access layer from the business logic by providing a collection-like interface to access domain objects. It helps keep data access logic centralized and makes the co…

SOLID Read answer
Mid PDF
How do you implement Repository pattern with Entity Framework?

Short answer: Here's a basic example: // Entity public class Product Example code { public int Id { get; set; } public string Name { get; set; } } // Generic Repository Interface public interface IRepository<T> whe…

SOLID Read answer
Mid PDF
What are the benefits of using Repository pattern?

Short answer: Separation of concerns between business and data access layers Improved testability (can mock repositories) Centralized query logic for maintainability Easier to switch persistence implementations Promotes…

SOLID Read answer
Mid PDF
How do you handle complex queries in the Repository pattern?

Short answer: Add custom methods in a specialized repository interface (e.g., IProductRepository) Use Specification pattern or LINQ expressions Inject DbContext into repository if needed for advanced queries Optionally,…

SOLID Read answer
Mid PDF
What are potential drawbacks of Repository pattern?

Short answer: Over-abstraction: Can add unnecessary complexity for simple apps. Duplication: May duplicate what EF Core already provides (since EF is already a repository/unit-of-work pattern). Hides EF Core features: Ma…

SOLID Read answer
Junior PDF
What is the Unit of Work pattern?

Short answer: The Unit of Work pattern is a design pattern used to maintain a list of operations to be performed within a single transaction. It ensures that all operations either succeed or fail together, providing cons…

SOLID Read answer
Mid PDF
How does Unit of Work complement the Repository pattern?

Short answer: The Repository pattern abstracts the data access layer, providing a simplified interface to data operations. The Unit of Work pattern complements it by managing multiple repositories and ensuring that all c…

SOLID Read answer
Mid PDF
How do you implement Unit of Work in a .NET application?

Short answer: In a .NET application (especially using Entity Framework), the Unit of Work is typically implemented around the DbContext, as it already tracks changes and handles transactions. Here's a simplified example:…

SOLID Read answer
Mid PDF
What are the benefits of Unit of Work in managing transactions?

Short answer: Transactional consistency: All changes across repositories are saved in a single transaction. Explain a bit more Centralized commit: All changes are committed through one method (Complete()), improving cont…

SOLID Read answer
Mid PDF
Can you combine Unit of Work with Dependency Injection?

Short answer: Yes, combining Unit of Work with Dependency Injection (DI) is a best practice in modern .NET applications. DI allows the Unit of Work to be injected into services or controllers, managing its lifecycle effe…

SOLID Read answer
Junior PDF
What is Dependency Injection and why is it useful?

Short answer: Dependency Injection (DI) is a design pattern that allows an object to receive its dependencies from an external source rather than creating them itself. This promotes loose coupling, enhances testability,…

SOLID Read answer
Mid PDF
How does .NET Core support Dependency Injection out of the box?

Short answer: .NET Core has a built-in DI container that's tightly integrated into the framework. When you create a new ASP.NET Core project, DI is configured automatically and used in controllers, middleware, services,…

SOLID Read answer
Mid PDF
How do you register services for DI in ASP.NET Core?

Short answer: Services are registered in the Program.cs or Startup.cs file using the IServiceCollection interface. Example code builder.Services.AddTransient<IProductService, ProductService>(); builder.Services.Add…

SOLID Read answer
Junior PDF
What is the difference between Scoped, Singleton, and Transient lifetimes?

Short answer: Transient: A new instance is created every time it is requested. Scoped: A single instance is created per request/HTTP request. Singleton: A single instance is created and shared across the application life…

SOLID Read answer
Mid PDF
How do you handle circular dependencies in DI?

Short answer: Circular dependencies occur when two or more services depend on each other, creating an infinite loop. To handle them: Refactor the code to remove tight coupling. Use interfaces or events to break the cycle…

SOLID Read answer
Mid PDF
What are the advantages of using DI in unit testing?

Short answer: Easier mocking of dependencies using frameworks like Moq or NSubstitute. No need to instantiate real implementations (e.g., database access) for tests. Improved isolation of the unit under test. Faster, mor…

SOLID Read answer
Mid PDF
Can DI be used without a DI container?

Short answer: How? Yes, DI can be implemented manually without using a DI container. You simply pass dependencies through constructors or methods: public class OrderService Example code { private readonly IOrderRepositor…

SOLID Read answer
Mid PDF
Can DI be used without a DI container? How?

Short answer: Yes, DI can be implemented manually without using a DI container. Explain a bit more You simply pass dependencies through constructors or methods: public class OrderService { private readonly IOrderReposito…

SOLID Read answer
Mid PDF
What are common pitfalls when implementing DI?

Short answer: Over-injection (too many dependencies in one class – violates SRP) Service locator anti-pattern Incorrect lifetimes, leading to memory leaks or unintended reuse Tight coupling to the DI container (e.g., usi…

SOLID Read answer
Mid PDF
How does DI relate to Inversion of Control (IoC)?

Short answer: Inversion of Control (IoC) is a broader principle where control over object creation and dependency resolution is transferred from the class itself to an external framework or container. Dependency Injectio…

SOLID Read answer
Junior PDF
What is the Single Responsibility Principle?

Short answer: The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it…

SOLID Read answer

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Payment gateways (Credit Card, PayPal, UPI, etc.) Sorting algorithms (QuickSort, MergeSort, BubbleSort) Authentication strategies (OAuth, JWT, LDAP) Compression algorithms (ZIP, RAR, TAR) Loggers (FileLogger, ConsoleLogger, DatabaseLogger)

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: It promotes the Open/Closed Principle by allowing you to add new strategies (algorithms or behaviors) without modifying the existing code. The context class uses an interface for the strategy, so new behavior can be added just by creating a new class that implements the interface—no need to touch existing logic.

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Aspect Strategy Pattern State Pattern Purpose Encapsulates interchangeable behaviors (algorithms).

Explain a bit more

Encapsulates states and transitions between them. Client Control Client decides which strategy to use. Object changes its own state internally. Behavior Switch Switched externally (e.g., passed as a parameter). Switched internally (e.g., via method call). Example Payment method selection. Document lifecycle (Draft → Published → Archived). Repository Design Pattern

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Applications? The Repository pattern abstracts the data access layer from the business logic by providing collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codebase easier to maintain, test, and swap out data sources (e.g., switching from EF Core to Dapper or an API). Say this in the… interview

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: The Repository pattern abstracts the data access layer from the business logic by providing a collection-like interface to access domain objects. It helps keep data access logic centralized and makes the codebase easier to maintain, test, and swap out data sources (e.g., switching from EF Core to Dapper or an API).

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Here's a basic example: // Entity public class Product

Example code

{
public int Id { get; set; }
public string Name { get; set; }
} // Generic Repository Interface public interface IRepository<T> where T : class
{ Task<IEnumerable<T>> GetAllAsync(); Task<T> GetByIdAsync(int id); Task AddAsync(T entity); void Update(T entity); void Delete(T entity); Task SaveAsync(); } // EF Core implementation public class Repository<T> : IRepository<T> where T : class
{
private readonly DbContext _context;
private readonly DbSet<T> _dbSet;
public Repository(DbContext context)
{
_context = context;
_dbSet = context.Set<T>();
}
public async Task<IEnumerable<T>> GetAllAsync() => await _dbSet.ToListAsync(); public async Task<T> GetByIdAsync(int id) => await _dbSet.FindAsync(id); public async Task AddAsync(T entity) => await _dbSet.AddAsync(entity); public void Update(T entity) => _dbSet.Update(entity);
public void Delete(T entity) => _dbSet.Remove(entity);
public async Task SaveAsync() => await _context.SaveChangesAsync(); }

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Separation of concerns between business and data access layers Improved testability (can mock repositories) Centralized query logic for maintainability Easier to switch persistence implementations Promotes cleaner and more organized code

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Add custom methods in a specialized repository interface (e.g., IProductRepository) Use Specification pattern or LINQ expressions Inject DbContext into repository if needed for advanced queries Optionally, break out complex queries into Query objects or services public interface IProductRepository : IRepository<Product>

Example code

{ Task<IEnumerable<Product>> GetProductsWithLowStockAsync(int threshold); }

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Over-abstraction: Can add unnecessary complexity for simple apps. Duplication: May duplicate what EF Core already provides (since EF is already a repository/unit-of-work pattern). Hides EF Core features: May obscure advanced capabilities like eager loading or projections. Extra boilerplate: Especially with generic repositories, which may not add much value. Unit of Work

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: The Unit of Work pattern is a design pattern used to maintain a list of operations to be performed within a single transaction. It ensures that all operations either succeed or fail together, providing consistency and managing changes to multiple business objects during a transaction. It coordinates the writing out of changes and resolves potential concurrency issues.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: The Repository pattern abstracts the data access layer, providing a simplified interface to data operations. The Unit of Work pattern complements it by managing multiple repositories and ensuring that all changes made through these repositories are committed in a single transaction. This combination separates concerns, promotes clean architecture, and maintains transactional integrity across multiple operations.

Real-world example (ShopNest)

ShopNest payment fees use Strategy: IFeeCalculator with UPI/Card implementations chosen at runtime.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: In a .NET application (especially using Entity Framework), the Unit of Work is typically implemented around the DbContext, as it already tracks changes and handles transactions. Here's a simplified example: // IUnitOfWork.cs public interface IUnitOfWork : IDisposable

Example code

{ IProductRepository Products { get; } ICustomerRepository Customers { get; } int Complete();
} // UnitOfWork.cs public class UnitOfWork : IUnitOfWork
{
private readonly AppDbContext _context;
public IProductRepository Products { get; private set; }
public ICustomerRepository Customers { get; private set; }
public UnitOfWork(AppDbContext context)
{
_context = context;
Products = new ProductRepository(_context);
Customers = new CustomerRepository(_context);
}
public int Complete()
{
return _context.SaveChanges(); // All changes in one transaction }
public void Dispose()
{ _context.Dispose(); }
} Then register it using Dependency Injection in Startup.cs or Program.cs: services.AddScoped<IUnitOfWork, UnitOfWork>();

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Transactional consistency: All changes across repositories are saved in a single transaction.

Explain a bit more

Centralized commit: All changes are committed through one method (Complete()), improving control and readability. Reduced code duplication: Prevents repeated save logic across repositories. Improved testability: Enables better unit testing by mocking a single Unit of Work instead of multiple repositories. Change tracking: Ensures that only modified entities are persisted, reducing unnecessary database operations.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Yes, combining Unit of Work with Dependency Injection (DI) is a best practice in modern .NET applications. DI allows the Unit of Work to be injected into services or controllers, managing its lifecycle effectively. This improves modularity, promotes loose coupling, and makes the application easier to maintain and test. Example using constructor injection in a service: public class OrderService

Example code

{
private readonly IUnitOfWork _unitOfWork;
public OrderService(IUnitOfWork unitOfWork)
{
_unitOfWork = unitOfWork;
}
public void PlaceOrder(Order order)
{ _unitOfWork.Orders.Add(order); _unitOfWork.Complete(); }
} Dependency Injection (DI)

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Dependency Injection (DI) is a design pattern that allows an object to receive its dependencies from an external source rather than creating them itself. This promotes loose coupling, enhances testability, and simplifies code maintenance. Benefits: Improves modularity Enables easier unit testing (via mock dependencies) Promotes adherence to SOLID principles (especially the Dependency Inversion Principle)

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: .NET Core has a built-in DI container that's tightly integrated into the framework. When you create a new ASP.NET Core project, DI is configured automatically and used in controllers, middleware, services, etc. You register dependencies in the Program.cs or Startup.cs file using IServiceCollection.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Services are registered in the Program.cs or Startup.cs file using the IServiceCollection interface.

Example code

builder.Services.AddTransient<IProductService, ProductService>(); builder.Services.AddScoped<IOrderService, OrderService>(); builder.Services.AddSingleton<ILoggingService, LoggingService>();

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Transient: A new instance is created every time it is requested. Scoped: A single instance is created per request/HTTP request. Singleton: A single instance is created and shared across the application lifetime. Lifetime Created Per Use Case Transient Every injection Lightweight, stateless services Scoped HTTP Request Web services handling per-request data Singleton App lifetime Logging, configuration, cache

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Circular dependencies occur when two or more services depend on each other, creating an infinite loop. To handle them: Refactor the code to remove tight coupling. Use interfaces or events to break the cycle. Consider using property injection carefully (not recommended as a first choice). Rethink your design – circular dependencies often indicate architectural issues.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Easier mocking of dependencies using frameworks like Moq or NSubstitute. No need to instantiate real implementations (e.g., database access) for tests. Improved isolation of the unit under test. Faster, more reliable tests due to lack of external dependency reliance.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: How? Yes, DI can be implemented manually without using a DI container. You simply pass dependencies through constructors or methods: public class OrderService

Example code

{
private readonly IOrderRepository _repo;
public OrderService(IOrderRepository repo)
{
_repo = repo;
}
} // Manual injection var repo = new OrderRepository();
var service = new OrderService(repo); This is suitable for small or simple applications, though not scalable for large apps.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Yes, DI can be implemented manually without using a DI container.

Explain a bit more

You simply pass dependencies through constructors or methods: public class OrderService { private readonly IOrderRepository _repo; public OrderService(IOrderRepository repo) { _repo = repo; } } // Manual injection var repo = new OrderRepository(); var service = new OrderService(repo); This is suitable for small or simple applications, though not scalable for large apps. Yes, DI can be implemented manually without using a DI container. You simply pass dependencies through constructors or methods: public class OrderService { private readonly IOrderRepository _repo; public OrderService(IOrderRepository repo)

Example code

{
_repo = repo;
}
} // Manual injection var repo = new OrderRepository();
var service = new OrderService(repo); This is suitable for small or simple applications, though not scalable for large apps.

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Over-injection (too many dependencies in one class – violates SRP) Service locator anti-pattern Incorrect lifetimes, leading to memory leaks or unintended reuse Tight coupling to the DI container (e.g., using container APIs in business logic) Circular dependencies due to poor design Registering services in the wrong order or not at all

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: Inversion of Control (IoC) is a broader principle where control over object creation and dependency resolution is transferred from the class itself to an external framework or container. Dependency Injection is a specific implementation of IoC, where the dependencies are injected into a class rather than the class creating them internally. So, DI is one way to achieve IoC. Single Responsibility Principle (SRP)

Real-world example (ShopNest)

Patterns in ShopNest should solve a real pain (swappable payments, test seams)—not be added for decoration.

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

Design Patterns & SOLID Design Patterns in C# · SOLID

Short answer: The Single Responsibility Principle (SRP) states that a class should have only one reason to change. In other words, it should have only one responsibility or job. Each class should do one thing, and do it well. For example, a class that handles user authentication should not also be responsible for logging or sending emails.

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