Spring Questions Flashcards

1
Q

What is Spring Framework?

A

a. It is a lightweight framework that is loosely coupled used to create enterprise applications.

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

What are the advantages of Spring Framework

A

a. Layered architecture
b. POJO programming
c. Dependency Injection and Inversion of Control
d. Open source

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

What are the features of Spring

A

a. Lightweight - optimized for memory
b. IOC
c. AOP
d. Container
e. MVC Framework
f. Transaction Management
g. JDBC exception handling

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

How many modules are in spring and what are they

A

a. There are8 modules
b. Test module
c. AOP module
d. Aspects module
e. Instrumentation module
f. Core Container module - beans, core, context
g. Messaging Module
h. Data Access module - orm, jdbc, jms
i. Web module - web, servlet, websocket

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

What is the Spring Configuration file?

A

a. Is an xml file that contains information about the various classes that make up a system and describes how those classes are configured and introduced to each other

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

What are the major features in the different versions of spring

A

a. Spring 2.5 - annotation driven configuration made possible
b. Spring 3.0 - made great use of java 5 language improvements
c. Spring 4.0 - first version to fully support java features

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

What is the Spring IOC Container

A

a. Is used to create the objects in an application, configure them in an xml file and wire them together.
b. the container also manages the lifecycle of the objects from creation to destruction
c. Uses dependency injection to manage the components

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

What do you mean by Dependency Injection

A

a. Means we don’t create objects but describe how they should be created
b. We don’t directly connect components and services together in code but describe which services are needed by which components in a config file
c. The IOC container is then responsible for hooking everything up

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

What are the types of dependency injection

A

a. Constructor injection - dependencies are provided as constructor parameters
b. Setter injection - dependencies are provided via setter methods
c. Interface injection - dependencies are provided through an interface

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

Example of Tight Coupling

A

a. Person class with attributes name, id, age has an(has-a) address object
b. Address class has it’s own attributes - id, street, zip, city, state
c. In the person constructor, an instance of address is made
Person() { address = new Address()}
d. This creates tight coupling as we can’t create an address without creating a person

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

How Spring solves the tight coupling of Person and Address object.

A

a. Constructor injection = Person(Address a){ address = a; }

b. Setter injuction = person.setAddress(new Address());

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

How many types of IOC containers are there in Spring

A

a. There are two types - BeanFactory and ApplicationContext
b. BeanFactory - is a facory class that instantiates the bean whenever it is asked for by clients
c. ApplicationContext - an interface build on top of the BeanFactory interface

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

What is the difference between BeanFactory and ApplicationContext

A

a. Both are types of IOC
b. BeanFactory - constructs the objects only when they are requested for or lazy initialization
c. ApplicationContext - constructs the objects even when we do not request or eager initialization

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

What is a Spring Bean

A

a. The objects that form the backbone of the application
b. They are objects that are instantiated, assembled and managed by the ioc
c. They are created with the configuration metadata

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

How configuration metadata is provided to the spring container

A

a. XML config file
b. Annotation based
c. Java based configuration

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

What are the scopes of the bean

A

a. Singleton - one object per ioc container
b. Prototype - creates any number of object instances of the bean
c. Request - http request object(spring applicationcontext)
d. Session - http session
e. Global session =

17
Q

How is annotation wiring turned on

A

a. in the spring config file, add tag within your beans tag.