Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: Decorator Pattern

Front

How does the Decorator pattern add new behavior to an object?

By wrapping the object with a decorator that implements the same interface. The Decorator pattern adds new functionality…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

What role does Spring Boot's IoC container play in managing application components?

The IoC container manages the lifecycle and dependencies of application components. In Spring Boot, the Inversion of Control…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

Why can transaction self-invocation lead to issues in Spring Boot?

Self-invocation bypasses Spring's transactional proxy mechanism. In Spring Boot, transaction management is often handled by proxies. When a…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

Why does mockability on testing with constructor injection matter in practice?

Constructor injection enhances testability by allowing easy substitution of dependencies. Constructor injection simplifies unit testing by making it…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

How does using 'final' fields with constructor injection benefit immutability?

Final fields ensure that dependencies cannot be changed after object creation. When you declare fields as 'final' and…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

Why is constructor injection considered more reliable than field injection?

Constructor injection ensures that dependencies are provided at object creation time. Constructor injection allows for dependencies to be…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

How does Spring Boot handle bean instantiation order with constructor injection?

Spring resolves constructor-injected dependencies before instantiation. Spring Boot ensures that all dependencies required by a constructor are resolved…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

Why use Spring Boot's IoC container for dependency management?

It manages lifecycle and dependencies, promoting loose coupling. Spring Boot’s IoC container automatically handles the instantiation, configuration, and…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

How does Spring handle multiple beans of the same type being injected?

Spring uses type and @Qualifier annotations to resolve multiple beans. When multiple beans of the same type exist,…

View Card →
Flashcard Study

Java: Constructor vs Field Injection

Front

Why is @Autowired on private fields discouraged?

Private field injection reduces visibility and complicates testing. Using @Autowired on private fields hides dependencies, making it harder…

View Card →