Backend knowledge Flashcards

1
Q

What is the purpose of the @Autowired annotation?

A

The @Autowired annotation is used for automatic dependency injection in Spring Boot. It tells Spring to automatically inject a bean or component into a class where @Autowired is used

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are different methods of dependency injection in Spring Boot and which is the preferred one?

A

Constructor injection - preferred
Field Injection
Setter Injection

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the advantage of using setter dependency injection?

A

Setter injection allows for optional dependencies and the ability to change dependencies at runtime

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is IoC (Inversion of Control)?

A

Inversion of Control (IoC) is a design principle where a framework controls the flow and dependencies of your application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Singleton pattern and how is it utilized in Spring Boot?

A

The Singleton pattern ensures that a class has only one instance, and it provides a global point of access to that instance. In Spring Boot, beans like Services and Controllers are singletons by default, meaning there’s only one instance of a bean, and it’s shared across the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Factory Pattern?

A

The Factory Pattern is a creational design pattern that provides an interface for creating objects but lets subclasses alter the type of objects that will be created.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Observer Pattern?

A

The Observer Pattern is a behavioral design pattern where an object (the subject) maintains a list of its dependents (observers) and notifies them of state changes, allowing multiple objects to stay in sync with the subject’s state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain Spring MVC

A

Spring MVC (Model-View-Controller) is a framework within the Spring ecosystem for building web applications. It separates an application into three interconnected components (Model, View, Controller).
Spring MVC simplifies web application development by providing a structured way to handle HTTP requests and render responses.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Explain @Configuration annotation

A

Spring Configuration annotation indicates that the class has @Bean definition methods. So Spring container can process the class and generate Spring Beans to be used in the application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we inject value from properties file into Spring Boot class variable?

A

We use @Value annotation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How can you enhance the security of an application?

A

We can use authentication provider like Keycloak.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What practice can help mitigate security risks when processing user-provided data in your application?

A

Validation of user sent data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How can you define an endpoint in Controller Class in Spring Boot? (any method)

A

Example: @GetMapping(“/path”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you typically organize the components and layers in a Spring Boot application to maintain a clean and structured codebase?

A

We divide it into Controller, Service, Repository, Model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly