Spring Flashcards

1
Q

Primary functions of the spring container.

A

Create & manage objects (IoC) and inject object’s dependencies (DI).

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

3 ways of configuring a spring container.

A
  • XML config file (legacy)
  • Java annotations (modern)
  • Java source code (modern)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to create a spring container.

A

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext (“configFileName.xml”);

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

How to retrieve beans from container.

A

Coach theCoach = context.getBean (“myCoach”, Coach.class);

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

What is dependency injection?

A

The spring object factory will basically give you the objects you requested fully assembled. You outsource the construction & injection of your object to an external entity.

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

3 types of dependency injection.

A
  • constructor injection
  • setter injection
  • autowiring
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

what is setter injection?

A

inject dependencies by calling setter method on your class

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

what is bean scope?

A

the life cycle of a bean.

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

what does bean scope tell you?

A

How long the bean lives, how many instances are created, how the bean is shared.

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

what is the default scope for a bean?

A

singleton

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

what is a singleton with respect to beans?

A

The spring container creates only one instance of the bean. all requests for the bean will return a shared reference to the SAME bean.

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

What type of custom code can be added?

A

Bean init & Bean destruction code.

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

what are java annotations?

A

special labels/markers added to java classes that provide meta-data about the class.

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