All 49 questions
What is dependency injection, and how does a dependency injection container work?
Asked in 38 of 347 interviews · last asked Oct 21 · Concept · Junior
Show answer
Dependency injection means a class receives its dependencies from outside instead of creating them itself. This supports loose coupling, easier testing, and easier maintenance. A DI container uses service registrations to find or create dependencies and supply them to objects. It also manages configured lifetimes, such as transient, scoped, or singleton in .NET.
- Constructor injection makes required dependencies clear.
- Tests can supply fake implementations instead of real services.
- DI does not require a container; you can supply dependencies yourself.
- In .NET, transient means each resolution, scoped means once per scope, and singleton means one shared instance.
What the interviewer checks: The interviewer checks whether you understand DI’s benefits and can separate injection from the container’s role.
Common mistake (in 8 of 20 reviewed answers): Many answers forget that DI helps testing and maintenance by letting you replace dependencies without changing the class.
Other ways it was asked
- “What is dependency injection?”
- “What is dependency injection, and when would you use it?”
- “Can you explain what dependency injection is?”
How do transient, scoped, and singleton dependency injection lifetimes work in ASP.NET Core?
Asked in 8 of 347 interviews · last asked Sep 18 · Concept · Mid-level
Show answer
Transient creates a new instance each time the container resolves it. Scoped reuses one instance within a scope, usually one HTTP request. Singleton reuses one instance for the root container's lifetime and must be safe for concurrent use. Choose based on how long state should live and whether sharing is safe.
- Use transient for lightweight services that do not need shared state, such as a formatter.
- Use scoped for request-level work; AddDbContext registers DbContext as scoped by default.
- Use singleton for shared, thread-safe services, such as an in-memory cache.
- Injecting DbContext into a singleton fails scope validation; without validation, requests may share a non-thread-safe context.
What the interviewer checks: The interviewer checks whether you understand instance reuse, request boundaries, and the risks of sharing services across requests.
Other ways it was asked
- “Can you explain the differences between transient, scoped, and singleton service lifetimes in ASP.NET Core, and give a concrete example of when you would use each?”
- “In ASP.NET Core, what's the difference between transient, scoped, and singleton lifetimes?”
- “Explain transient, scoped, and singleton lifetimes in ASP.NET Core.”
What is inversion of control?
Asked in 5 of 347 interviews · last asked Oct 7 · Concept · Junior
Show answer
Inversion of control (IoC) means handing control of part of your program to a framework or container. In Spring, the container creates and manages objects called beans and supplies their dependencies. Dependency injection is one way to apply IoC: objects receive what they need instead of creating it themselves.
- IoC is a broader principle than dependency injection.
- Spring manages bean creation, wiring, and lifecycle.
- Dependency injection helps separate components and makes them easier to test.
What the interviewer checks: The interviewer wants to know whether you understand who controls object creation and how IoC relates to dependency injection.
Other ways it was asked
- “What is inversion of control (IoC)?”
- “What does inversion of control mean in a Spring application?”
- “What is inversion of control in Spring Boot?”
How do constructor, setter, and field injection compare, and which would you prefer?
Asked in 3 of 347 interviews · last asked Oct 21 · Concept · Mid-level
Other ways it was asked
- “Why is constructor injection preferred over field injection?”
- “Which type of dependency injection is preferred, and why?”
- “Which is better: constructor injection or setter injection?”
What is a captive dependency in .NET dependency injection, and why can it cause problems?
Asked in 2 of 347 interviews · last asked Sep 29 · Concept · Mid-level
Other ways it was asked
- “What is a captive dependency in dependency injection?”
What are the benefits of registering an interface with its implementation and choosing its lifetime in the dependency injection container?
Asked in 2 of 347 interviews · last asked Oct 15 · Concept · Mid-level
Other ways it was asked
- “How do you register an interface with its concrete implementation in a dependency injection container?”
How does dependency injection work in Python, and when would you use it?
Asked once · last asked Aug 13 · Concept · Mid-level
Other ways it was asked
- “Why is dependency injection used in Python applications?”
Can you explain dependency injection in ASP.NET Core?
Asked once · last asked Oct 10 · Concept · Mid-level
What dependency injection mechanisms are used in Android, how do they work, and what are their advantages and disadvantages?
Asked once · last asked Feb 10 · Concept · Senior
What are the main limitations of Koin for dependency injection in Android?
Asked once · last asked Feb 10 · Concept · Mid-level
How would you use dependency injection in Laravel, for example to inject a service or a built-in Laravel service?
Asked once · last asked Feb 10 · Concept · Mid-level
Why might you instantiate services and an API client manually instead of using Spring or a similar framework?
Asked once · last asked Mar 5 · Concept · Mid-level
What is the relationship between inversion of control and dependency injection, and how does Spring illustrate inversion of control?
Asked once · last asked Mar 6 · Concept · Mid-level
In a senior-level MVC architecture, how do you enforce dependency inversion in controllers—for example, with interfaces and dependency-injection container bindings—while keeping framework coupling minimal?
Asked once · last asked Mar 26 · Design · Senior
Why is it better to pass dependencies through a constructor rather than instantiate classes directly with `new`?
Asked once · last asked Apr 27 · Concept · Mid-level
How does dependency injection help reduce coupling between classes?
Asked once · last asked Apr 27 · Concept · Mid-level
Can you give an example of how instantiating a class with `new` tightly couples code to a specific implementation?
Asked once · last asked Apr 27 · Concept · Mid-level
How does Magento create an object and pass it the dependencies declared in its constructor?
Asked once · last asked Apr 27 · Concept · Senior
What are virtual types in Magento, and what are they used for?
Asked once · last asked Apr 27 · Concept · Senior
How does Magento determine which class to instantiate for an interface declared in a constructor, and where is that mapping configured?
Asked once · last asked Apr 27 · Concept · Senior
When implementing Java or Spring Boot processes with dependencies such as databases and external APIs, how do you design them to make testing easier?
Asked once · last asked May 19 · Design · Senior
Can you explain the concept of dependency injection in NestJS?
Asked once · last asked May 22 · Concept · Mid-level
If services A and B are registered, how would you make service A receive and use service B through dependency injection?
Asked once · last asked Jun 11 · Scenario · Mid-level
How can singleton hell emerge in a large Unity project that uses dependency injection, a service locator, and ScriptableObject events?
Asked once · last asked Jul 17 · Concept · Senior
Other ways it was asked
- “How would you avoid singleton hell in a large Unity project?”
How does dependency injection resolve a user service interface to its concrete implementation?
Asked once · last asked Jul 20 · Concept · Mid-level
How would you apply dependency injection in an iOS project?
Asked once · last asked Aug 7 · Scenario · Mid-level
How do you inject a service into an ASP.NET Core MVC controller, what service lifetime would you typically use, and why does that choice matter in the context of a web request?
Asked once · last asked Aug 12 · Concept · Mid-level
What are property injection and method injection?
Asked once · last asked Aug 17 · Concept · Mid-level
What problems does dependency injection solve, which libraries support it, and what dependency lifetimes can you configure?
Asked once · last asked Sep 4 · Concept · Mid-level
Other ways it was asked
- “Could you tell me more details about dependency injection: what problem it solves, which library you have used, and which lifetimes you have used?”
When, if ever, is it acceptable to resolve services directly from IServiceProvider using the Service Locator pattern, and what are the risks?
Asked once · last asked Sep 10 · Scenario · Senior
In a circular dependency between two Spring beans, which type of dependency injection should you use?
Asked once · last asked Sep 11 · Scenario · Mid-level
Can you write code showing constructor injection?
Asked once · last asked Sep 18 · Write code · Mid-level
What are the different service lifetimes available in a DI container?
Asked once · last asked Sep 29 · Concept · Mid-level
When is a singleton service appropriate in dependency injection?
Asked once · last asked Sep 29 · Concept · Mid-level
What is the difference between AddScoped and TryAddScoped?
Asked once · last asked Sep 29 · Concept · Senior
What is the idea behind IoC, and is DI also IoC?
Asked once · last asked Sep 29 · Concept · Mid-level
If the function depends on an external API or the current time, how would you suggest making it testable and deterministic?
Asked once · last asked Oct 14 · Scenario · Junior
In an ASP.NET Core controller, what would you inject: a concrete class or an abstraction such as an interface?
Asked once · last asked Oct 15 · Concept · Mid-level
Where do you register which class implements an interface in an ASP.NET Core application?
Asked once · last asked Oct 15 · Concept · Mid-level
What are the benefits and trade-offs of instantiating all repositories in a mobile app's root routing view and having view models depend only on protocols?
Asked once · last asked Oct 19 · Design · Mid-level
Other ways it was asked
- “Why did you use AppRouteView to instantiate all repositories and have view models depend only on protocols? What benefits and trade-offs did that create?”
What is dependency injection in FastAPI, and how does it work behind the scenes?
Asked once · last asked Oct 22 · Concept · Mid-level
What are the main differences in dependency injection between .NET Framework and .NET 10?
Asked once · last asked Oct 23 · Concept · Senior
Using a metaphor, how would you explain dependency injection in .NET?
Asked once · last asked Jul 17 · Concept · Mid-level
Can you explain dependency injection in one or two or three sentences?
Asked once · last asked Sep 9 · Concept · Junior
How would you use Kotlin Multiplatform and dependency injection in a project, and how would you decide whether to keep an existing solution?
Asked once · last asked Feb 10 · Scenario · Senior
What is dependency injection in Magento?
Asked once · last asked Apr 27 · Concept · Junior
What is an IoC container?
Asked once · last asked Sep 1 · Concept · Junior
What does IoC stand for in software development?
Asked once · last asked Oct 14 · Concept · Junior
What kinds of dependencies do you inject in a .NET Core application?
Asked once · last asked Oct 15 · Concept · Junior
More OOP and Design Patterns interview questions
- All OOP and Design Patterns interview questions
- OOP Basics Interview Questions
- Inheritance, Polymorphism, and Interfaces Interview Questions
- SOLID Principles and Object Design Interview Questions
- Design Patterns Interview Questions
How this list is made
Every question here was asked by a real interviewer in a real job interview that a candidate ran MeetAssist in. After the call, the interviewer's questions are pulled from the transcript. Practice sessions, tests, exams and anything that was not a job interview are dropped.
Questions are rewritten so they make sense on their own: names of people, employers and clients are removed, and speech-to-text mistakes are fixed. Small talk, logistics and questions about one candidate's own résumé are left out. Rephrasings of the same question are merged, and the count is the number of different interviews it came up in.
The interviews come from candidates who use MeetAssist, so they lean towards software, data and AI roles: the shares describe these interviews, not every OOP and Design Patterns interview. Answers to the most asked questions are written and checked by an editor; a "common mistake" is shown only when reviews of real answers in these interviews show it, with the count.
347 interviews, 240 candidates, Sep 2025 to Oct 2026. Updated every month with new interviews.
Or add the Chrome extension