Dependency Injection interview questions

18 real Dependency Injection questions from the FastAPI bank, as asked in Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd — free to start.

1. What is Depends?

Junior
  1. A.a dependency that itself declares Depends on another, forming a resolved chain of providers
  2. B.the marker that declares a callable whose result the framework resolves and injects as a handler argument
  3. C.the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  4. D.a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
Reveal the answer + AI explanation — free account

2. Which term means: "the marker that declares a callable whose result the framework resolves and injects as a handler argument"?

Junior
  1. A.Path operation dependencies list
  2. B.Depends
  3. C.Yield dependency
  4. D.Sub-dependency
Reveal the answer + AI explanation — free account

3. Which statement is correct?

Junior
  1. A.Depends — a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
  2. B.Depends — the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  3. C.Depends — the marker that declares a callable whose result the framework resolves and injects as a handler argument
  4. D.Depends — the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
Reveal the answer + AI explanation — free account

4. What is Sub-dependency?

Mid
  1. A.the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  2. B.the marker that declares a callable whose result the framework resolves and injects as a handler argument
  3. C.a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
  4. D.a dependency that itself declares Depends on another, forming a resolved chain of providers
Reveal the answer + AI explanation — free account

6. Which statement is correct?

Mid
  1. A.Sub-dependency — a dependency that itself declares Depends on another, forming a resolved chain of providers
  2. B.Sub-dependency — the default behavior where a provider called more than once in a single request is executed only once and its result reused
  3. C.Sub-dependency — the marker that declares a callable whose result the framework resolves and injects as a handler argument
  4. D.Sub-dependency — the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
Reveal the answer + AI explanation — free account

7. What is Per-request dependency caching?

Mid
  1. A.the default behavior where a provider called more than once in a single request is executed only once and its result reused
  2. B.a dependency that itself declares Depends on another, forming a resolved chain of providers
  3. C.the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  4. D.a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
Reveal the answer + AI explanation — free account

8. Which term means: "the default behavior where a provider called more than once in a single request is executed only once and its result reused"?

Mid
  1. A.Path operation dependencies list
  2. B.Sub-dependency
  3. C.Yield dependency
  4. D.Per-request dependency caching
Reveal the answer + AI explanation — free account

9. Which statement is correct?

Mid
  1. A.Per-request dependency caching — the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
  2. B.Per-request dependency caching — the marker that declares a callable whose result the framework resolves and injects as a handler argument
  3. C.Per-request dependency caching — the default behavior where a provider called more than once in a single request is executed only once and its result reused
  4. D.Per-request dependency caching — a dependency that itself declares Depends on another, forming a resolved chain of providers
Reveal the answer + AI explanation — free account

10. What is Yield dependency?

Senior
  1. A.the default behavior where a provider called more than once in a single request is executed only once and its result reused
  2. B.a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
  3. C.the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
  4. D.a dependency that itself declares Depends on another, forming a resolved chain of providers
Reveal the answer + AI explanation — free account

11. Which term means: "a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session"?

Senior
  1. A.Yield dependency
  2. B.Per-request dependency caching
  3. C.Sub-dependency
  4. D.use_cache disabled
Reveal the answer + AI explanation — free account

12. Which statement is correct?

Senior
  1. A.Yield dependency — the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
  2. B.Yield dependency — a dependency that itself declares Depends on another, forming a resolved chain of providers
  3. C.Yield dependency — the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  4. D.Yield dependency — a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
Reveal the answer + AI explanation — free account

13. What is Path operation dependencies list?

Mid
  1. A.the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
  2. B.a dependency that itself declares Depends on another, forming a resolved chain of providers
  3. C.the default behavior where a provider called more than once in a single request is executed only once and its result reused
  4. D.a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
Reveal the answer + AI explanation — free account

14. Which term means: "the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value"?

Mid
  1. A.Path operation dependencies list
  2. B.Depends
  3. C.use_cache disabled
  4. D.Per-request dependency caching
Reveal the answer + AI explanation — free account

15. Which statement is correct?

Mid
  1. A.Path operation dependencies list — the marker that declares a callable whose result the framework resolves and injects as a handler argument
  2. B.Path operation dependencies list — the decorator argument that runs providers for their side effects, such as auth checks, without injecting their return value
  3. C.Path operation dependencies list — a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
  4. D.Path operation dependencies list — the default behavior where a provider called more than once in a single request is executed only once and its result reused
Reveal the answer + AI explanation — free account

16. What is use_cache disabled?

Senior
  1. A.the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  2. B.a dependency that itself declares Depends on another, forming a resolved chain of providers
  3. C.the default behavior where a provider called more than once in a single request is executed only once and its result reused
  4. D.the marker that declares a callable whose result the framework resolves and injects as a handler argument
Reveal the answer + AI explanation — free account

17. Which term means: "the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result"?

Senior
  1. A.Sub-dependency
  2. B.use_cache disabled
  3. C.Per-request dependency caching
  4. D.Depends
Reveal the answer + AI explanation — free account

18. Which statement is correct?

Senior
  1. A.use_cache disabled — a provider written as a generator that yields a value and runs teardown code after the response, ideal for closing a database session
  2. B.use_cache disabled — the option set to False on Depends to force a provider to re-run rather than reuse its cached per-request result
  3. C.use_cache disabled — a dependency that itself declares Depends on another, forming a resolved chain of providers
  4. D.use_cache disabled — the marker that declares a callable whose result the framework resolves and injects as a handler argument
Reveal the answer + AI explanation — free account

Free to start

Answers, AI explanations, and a scored voice mock interview

Sign up free to check your answers with explanations, ask the AI tutor anything on any question, and take one full AI mock interview — scored like a real panel.

Practice Dependency Injection free