Spring Questions Flashcards
What is Spring Framework?
a. It is a lightweight framework that is loosely coupled used to create enterprise applications.
What are the advantages of Spring Framework
a. Layered architecture
b. POJO programming
c. Dependency Injection and Inversion of Control
d. Open source
What are the features of Spring
a. Lightweight - optimized for memory
b. IOC
c. AOP
d. Container
e. MVC Framework
f. Transaction Management
g. JDBC exception handling
How many modules are in spring and what are they
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
What is the Spring Configuration file?
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
What are the major features in the different versions of spring
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
What is the Spring IOC Container
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
What do you mean by Dependency Injection
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
What are the types of dependency injection
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
Example of Tight Coupling
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 Spring solves the tight coupling of Person and Address object.
a. Constructor injection = Person(Address a){ address = a; }
b. Setter injuction = person.setAddress(new Address());
How many types of IOC containers are there in Spring
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
What is the difference between BeanFactory and ApplicationContext
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
What is a Spring Bean
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 configuration metadata is provided to the spring container
a. XML config file
b. Annotation based
c. Java based configuration