Beans & DI interview questions

30 Beans & DI questions from the Spring bank, written for Indian campus drives and tech interviews. Every question has a verified answer and an AI-tutor explanation on placd.

Free to start: the 2-minute IT readiness check — six questions and a result.

Take the free IT readiness check

or take a mock interview set up for this area

1. What is Dependency injection?

Junior
  1. A.wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  2. B.a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  3. C.supplying an object's collaborators from outside rather than having the object construct them itself
  4. D.the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing

Answer + AI explanation with Pro

2. Which term means: "supplying an object's collaborators from outside rather than having the object construct them itself"?

Junior
  1. A.Prototype scope
  2. B.@Configuration
  3. C.@Primary
  4. D.Dependency injection

Answer + AI explanation with Pro

3. Which statement is correct?

Junior
  1. A.Dependency injection — the default lifecycle where the container creates exactly one shared instance per context
  2. B.Dependency injection — a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  3. C.Dependency injection — a lifecycle where the container produces a brand-new instance on every request for that bean
  4. D.Dependency injection — supplying an object's collaborators from outside rather than having the object construct them itself

Answer + AI explanation with Pro

4. What is @Autowired?

Junior
  1. A.an annotation that disambiguates which candidate to inject when several beans of the same type exist
  2. B.an annotation that tells the container to resolve and inject a matching collaborator by type
  3. C.supplying an object's collaborators from outside rather than having the object construct them itself
  4. D.a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees

Answer + AI explanation with Pro

5. Which term means: "an annotation that tells the container to resolve and inject a matching collaborator by type"?

Junior
  1. A.@Autowired
  2. B.Field injection
  3. C.Constructor injection
  4. D.Singleton scope

Answer + AI explanation with Pro

6. Which statement is correct?

Junior
  1. A.@Autowired — an annotation marking one candidate as the default choice when multiple of a type could be injected
  2. B.@Autowired — wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  3. C.@Autowired — an annotation that tells the container to resolve and inject a matching collaborator by type
  4. D.@Autowired — the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing

Answer + AI explanation with Pro

7. What is Constructor injection?

Mid
  1. A.an annotation marking one candidate as the default choice when multiple of a type could be injected
  2. B.the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  3. C.wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  4. D.an annotation that tells the container to resolve and inject a matching collaborator by type

Answer + AI explanation with Pro

8. Which term means: "the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing"?

Mid
  1. A.Constructor injection
  2. B.@Bean
  3. C.Singleton scope
  4. D.@Qualifier

Answer + AI explanation with Pro

9. Which statement is correct?

Mid
  1. A.Constructor injection — an annotation that tells the container to resolve and inject a matching collaborator by type
  2. B.Constructor injection — a lifecycle where the container produces a brand-new instance on every request for that bean
  3. C.Constructor injection — the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  4. D.Constructor injection — the default lifecycle where the container creates exactly one shared instance per context

Answer + AI explanation with Pro

10. What is Field injection?

Mid
  1. A.a lifecycle where the container produces a brand-new instance on every request for that bean
  2. B.an annotation marking one candidate as the default choice when multiple of a type could be injected
  3. C.wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  4. D.a method-level annotation inside a configuration class declaring that the returned object should be registered in the container

Answer + AI explanation with Pro

11. Which term means: "wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability"?

Mid
  1. A.Dependency injection
  2. B.Field injection
  3. C.@Qualifier
  4. D.Constructor injection

Answer + AI explanation with Pro

12. Which statement is correct?

Mid
  1. A.Field injection — a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  2. B.Field injection — an annotation marking one candidate as the default choice when multiple of a type could be injected
  3. C.Field injection — a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees
  4. D.Field injection — wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability

Answer + AI explanation with Pro

13. What is Singleton scope?

Junior
  1. A.an annotation that disambiguates which candidate to inject when several beans of the same type exist
  2. B.an annotation marking one candidate as the default choice when multiple of a type could be injected
  3. C.a lifecycle where the container produces a brand-new instance on every request for that bean
  4. D.the default lifecycle where the container creates exactly one shared instance per context

Answer + AI explanation with Pro

14. Which term means: "the default lifecycle where the container creates exactly one shared instance per context"?

Junior
  1. A.Constructor injection
  2. B.Dependency injection
  3. C.@Configuration
  4. D.Singleton scope

Answer + AI explanation with Pro

15. Which statement is correct?

Junior
  1. A.Singleton scope — a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  2. B.Singleton scope — the default lifecycle where the container creates exactly one shared instance per context
  3. C.Singleton scope — the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  4. D.Singleton scope — a lifecycle where the container produces a brand-new instance on every request for that bean

Answer + AI explanation with Pro

16. What is Prototype scope?

Mid
  1. A.supplying an object's collaborators from outside rather than having the object construct them itself
  2. B.wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  3. C.an annotation marking one candidate as the default choice when multiple of a type could be injected
  4. D.a lifecycle where the container produces a brand-new instance on every request for that bean

Answer + AI explanation with Pro

17. Which term means: "a lifecycle where the container produces a brand-new instance on every request for that bean"?

Mid
  1. A.Dependency injection
  2. B.Singleton scope
  3. C.Prototype scope
  4. D.Constructor injection

Answer + AI explanation with Pro

18. Which statement is correct?

Mid
  1. A.Prototype scope — an annotation that disambiguates which candidate to inject when several beans of the same type exist
  2. B.Prototype scope — a lifecycle where the container produces a brand-new instance on every request for that bean
  3. C.Prototype scope — an annotation marking one candidate as the default choice when multiple of a type could be injected
  4. D.Prototype scope — the default lifecycle where the container creates exactly one shared instance per context

Answer + AI explanation with Pro

19. What is @Qualifier?

Mid
  1. A.an annotation that disambiguates which candidate to inject when several beans of the same type exist
  2. B.the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  3. C.a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  4. D.supplying an object's collaborators from outside rather than having the object construct them itself

Answer + AI explanation with Pro

20. Which term means: "an annotation that disambiguates which candidate to inject when several beans of the same type exist"?

Mid
  1. A.@Autowired
  2. B.Constructor injection
  3. C.@Qualifier
  4. D.@Configuration

Answer + AI explanation with Pro

21. Which statement is correct?

Mid
  1. A.@Qualifier — supplying an object's collaborators from outside rather than having the object construct them itself
  2. B.@Qualifier — an annotation marking one candidate as the default choice when multiple of a type could be injected
  3. C.@Qualifier — a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees
  4. D.@Qualifier — an annotation that disambiguates which candidate to inject when several beans of the same type exist

Answer + AI explanation with Pro

22. What is @Primary?

Mid
  1. A.an annotation that disambiguates which candidate to inject when several beans of the same type exist
  2. B.wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  3. C.an annotation marking one candidate as the default choice when multiple of a type could be injected
  4. D.an annotation that tells the container to resolve and inject a matching collaborator by type

Answer + AI explanation with Pro

23. Which term means: "an annotation marking one candidate as the default choice when multiple of a type could be injected"?

Mid
  1. A.@Bean
  2. B.Dependency injection
  3. C.@Primary
  4. D.@Autowired

Answer + AI explanation with Pro

24. Which statement is correct?

Mid
  1. A.@Primary — an annotation that tells the container to resolve and inject a matching collaborator by type
  2. B.@Primary — a lifecycle where the container produces a brand-new instance on every request for that bean
  3. C.@Primary — the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  4. D.@Primary — an annotation marking one candidate as the default choice when multiple of a type could be injected

Answer + AI explanation with Pro

25. What is @Bean?

Mid
  1. A.a lifecycle where the container produces a brand-new instance on every request for that bean
  2. B.the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  3. C.a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  4. D.the default lifecycle where the container creates exactly one shared instance per context

Answer + AI explanation with Pro

26. Which term means: "a method-level annotation inside a configuration class declaring that the returned object should be registered in the container"?

Mid
  1. A.Field injection
  2. B.@Configuration
  3. C.Prototype scope
  4. D.@Bean

Answer + AI explanation with Pro

27. Which statement is correct?

Mid
  1. A.@Bean — the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  2. B.@Bean — a lifecycle where the container produces a brand-new instance on every request for that bean
  3. C.@Bean — a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  4. D.@Bean — supplying an object's collaborators from outside rather than having the object construct them itself

Answer + AI explanation with Pro

28. What is @Configuration?

Mid
  1. A.the preferred wiring style passing dependencies as parameters, enabling immutable and final fields and easier unit testing
  2. B.an annotation marking one candidate as the default choice when multiple of a type could be injected
  3. C.a lifecycle where the container produces a brand-new instance on every request for that bean
  4. D.a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees

Answer + AI explanation with Pro

29. Which term means: "a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees"?

Mid
  1. A.@Bean
  2. B.Dependency injection
  3. C.@Configuration
  4. D.@Autowired

Answer + AI explanation with Pro

30. Which statement is correct?

Mid
  1. A.@Configuration — a class-level annotation marking a source of bean definitions whose factory methods are proxied for singleton guarantees
  2. B.@Configuration — a method-level annotation inside a configuration class declaring that the returned object should be registered in the container
  3. C.@Configuration — wiring directly onto a private member via reflection, discouraged because it hides dependencies and breaks plain testability
  4. D.@Configuration — an annotation that disambiguates which candidate to inject when several beans of the same type exist

Answer + AI explanation with Pro

Free to start

Start with a free readiness check

Sign up free for the 2-minute IT readiness check and a scored result. Answers, explanations and the AI tutor on every Beans & DI question come with Pro.

Take the free IT readiness check

or take a mock interview set up for this area

24,000+ questions & coding problemsSoftware & IT16,274 questionsGovernment jobs26 examsAptitudenew questions every timeAI practice interviewwith feedback65 topics to practiseMechanical1,149 questionsGATE ME9 papersEngineering Mathematics381 questions2-minute checkfreeDSA Problems1,422Civil1,005 questionsGATE CE9 papersCS Fundamentals1,209 questionsYour scores6 skillsSystem Design25Electrical / EEE1,047 questionsGATE EE9 papersRun your codeC++ · Java · PythonLow-Level Design144Electronics & Comm.975 questionsGATE EC9 papersAI help on every questionFull-Stack6,282Chemical1,005 questionsGATE CH9 papersAI whiteboardsystem designWork abroadEurope · remote · transfersESE ME1 paperGATE practice papers2019–2026ESE CE1 paperDate alertsbefore the last dateESE EE1 paperBehavioural courseHR round practiceESE ET1 paperResume optimizerProSSC JE ME1 paperApplication trackerSSC JE CE1 paperCompany-wise prepSSC JE EE1 paperRole roadmapsRRB JE1 subjectPriced in ₹UPI · cardsISRO SC1 paperGATE CS9 papersIBPS SO IT1 paperUGC NET CS1 paperSSC CGL26 papersIBPS PO26 papersRRB NTPC26 papersSSC CHSL26 papersIBPS Clerk26 papersSBI Clerk26 papersRRB Group D26 papersSSC CPO26 papersSSC GD26 papers