Ctrl K
Java · Mid-level · Theory

Which Spring bean scopes have you used, and what happens if you inject a prototype bean into a singleton?

~4 min by voice

How to approach it

The interviewer wants to see whether you understand the Spring bean lifecycle rather than just knowing the scope names. The key question is whether you see the trap: a prototype inside a singleton is created once, and whether you know how to get a new instance on every use.

Have you seen this question in a real interview?
Answers0
Avg. score—
Strong—
Practiced0
Topics
Similar questionsA Spring Boot service needs to accept report generation tasks, each of which takes several minutes. How would you organize running them inside the Java application? Mid-levelYou have a Spring Boot monolith that a team of thirty people has been developing for five years, and it's started slowing development down. How would you decide whether to split it into services or modularize it internally, and how would you carry out the changes? SeniorA method is annotated with @Transactional, but when an error occurs the data in the database isn't rolled back. What causes would you check? Mid-levelHow do you organize exception handling in a Spring application: where do you catch exceptions, and when do you use checked versus unchecked exceptions? Mid-levelWhat is dependency injection in Spring, and what is a bean? Junior

Answer by voice

The interviewer will ask this question and listen. Think out loud and ask for a hint if you need one. When you're done, pause or tap “That's my answer”. In about a minute, your score and the points you covered show up here.

Sign in to answer

Best with headphones · ~4 min