Java: Controllers, Services, Repositories
Why does a @Service in Spring architecture matter in this design?
It encapsulates business logic. Frame the concept in practical terms so you can explain it during interview discussion.…
View Card →Quick study sessions to strengthen memory and retain key concepts.
Why does a @Service in Spring architecture matter in this design?
It encapsulates business logic. Frame the concept in practical terms so you can explain it during interview discussion.…
View Card →How can you handle transaction self-invocation in a Spring application?
Refactor to externalize calls to a separate bean. To handle transaction self-invocation, refactor the method call to an…
View Card →Why is field injection often discouraged in Spring?
It hides dependencies and complicates testing. Field injection directly injects dependencies into fields, making dependencies less visible and…
View Card →Why does a @Configuration class in Spring matter in practice?
To define beans and configuration settings. @Configuration classes are used to define beans and their configurations explicitly. This…
View Card →When should you use a prototype scope in Spring?
For beans needing a new instance per use. Frame the concept in practical terms so you can explain…
View Card →Which scope of a Spring Bean and its implication is the default in Java?
Singleton; a single instance per Spring container. By default, Spring beans are singleton, meaning there's only one instance…
View Card →Why can transaction self-invocation be problematic in Spring?
Self-invocation bypasses proxy, ignoring @Transactional. In Spring, transactional behavior is managed by a proxy. When a method calls…
View Card →Why do teams use constructor injection in Spring in production code?
Constructor injection ensures dependencies are set and promotes immutability. Constructor injection in Spring enforces that all required dependencies…
View Card →How do @RestController and @Service differ in a Spring Boot app?
@RestController handles HTTP; @Service handles business logic. In Spring Boot, a @RestController is meant to manage HTTP requests…
View Card →How would you explain a common pitfall of using field injection in an interview?
Reduced testability and immutability. Frame the concept in practical terms so you can explain it during interview discussion.…
View Card →