Spring Boot

Spring Core - IoC & DI

Inversion of Control, Dependency Injection, annotations (@Component, @Autowired, @Bean), scopes, bean lifecycle

22 câu hỏi phỏng vấn·
Junior
1

What is Inversion of Control (IoC) in Spring?

Câu trả lời

IoC is a principle where the Spring framework manages object creation and lifecycle, rather than the developer. This reverses the traditional control flow where application code directly instantiates its dependencies. Spring uses an IoC container to manage beans and their dependencies declaratively.

2

What is a bean in Spring?

Câu trả lời

A bean is an object managed by the Spring IoC container. It is instantiated, configured and assembled by Spring according to configuration metadata (annotations, XML or Java config). Beans are the core of a Spring application and benefit from dependency injection.

3

What is the purpose of the @Component annotation?

Câu trả lời

The @Component annotation marks a class as a Spring bean to be automatically detected during component scanning enabled by @ComponentScan. Spring creates an instance of this class and places it in the IoC container with a default name (class in camelCase). It's the generic stereotype annotation from which @Service, @Repository and @Controller derive to bring specific business semantics.

4

What are the three types of dependency injection in Spring?

5

How does the @Autowired annotation work?

+19 câu hỏi phỏng vấn

Nắm vững Spring Boot cho lần phỏng vấn tiếp theo

Truy cập tất cả câu hỏi, flashcards, bài kiểm tra kỹ thuật, bài tập code review và mô phỏng phỏng vấn.

Bắt đầu miễn phí