You are on page 1of 6

FullStack.

Cafe - Kill Your Tech Interview

FullStack.Cafe - Kill Your Tech Interview

Q1: What is Spring? ☆

Topics: Spring

Answer:

Spring is an open source development framework for enterprise Java. The core features of the Spring Framework
can be used in developing any Java application, but there are extensions for building web applications on top of
the Java EE platform. Spring framework targets to make J2EE development easier to use and promote good
programming practice by enabling a POJO-based (Plain Old Java Object) programming model.

Q2: What are benefits of using Spring? ☆☆

Topics: Spring

Answer:

Following is the list of few of the great benefits of using Spring Framework:

Lightweight − Spring is lightweight when it comes to size and transparency. The basic version of spring
framework is around 2MB.
Inversion of control (IOC) − Loose coupling is achieved in spring using the technique Inversion of Control.
The objects give their dependencies instead of creating or looking for dependent objects.
Aspect oriented (AOP) − Spring supports Aspect oriented programming and enables cohesive
development by separating application business logic from system services.
Container − Spring contains and manages the life cycle and configuration of application objects.
MVC Framework − Spring's web framework is a well-designed web MVC framework, which provides a great
alternative to web frameworks such as Struts or other over-engineered or less popular web frameworks.
Transaction Management − Spring provides a consistent transaction management interface that can scale
down to a local transaction (using a single database, for example) and scale up to global transactions (using
JTA, for example).
Exception Handling − Spring provides a convenient API to translate technology-specific exceptions (thrown
by JDBC, Hibernate, or JDO, for example) into consistent, unchecked exceptions.

Q3: What are the different modules in Spring framework? ☆☆

Topics: Spring

Answer:

Following are the modules of the Spring framework:

Core module
Bean module
Context module
Expression Language module
JDBC module
ORM module

Page 1 of 6
FullStack.Cafe - Kill Your Tech Interview

OXM module
Java Messaging Service(JMS) module
Transaction module
Web module
Web-Servlet module
Web-Struts module
Web-Portlet module

Q4: What are Spring beans? ☆☆

Topics: Spring

Answer:

The objects that form the backbone of your application and that are managed by the Spring IoC container are
called beans. A bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC
container. These beans are created with the configuration metadata that you supply to the container, for
example, in the form of XML <bean/> definitions.

Q5: What does a bean definition contain? ☆☆

Topics: Spring

Answer:

The bean definition contains the information called configuration metadata which is needed for the container to
know the followings −

How to create a bean


Bean's lifecycle details
Bean's dependencies

Q6: How do you provide configuration metadata to the Spring


Container? ☆☆

Topics: Spring

Answer:

There are following three important methods to provide configuration metadata to the Spring Container −

XML based configuration file.


Annotation-based configuration
Java-based configuration

Q7: What is default scope of bean in Spring framework? ☆☆

Topics: Spring

Answer:

The default scope of bean is Singleton for Spring framework.

Page 2 of 6
FullStack.Cafe - Kill Your Tech Interview

Q8: What are ORM's Spring supports? ☆☆

Topics: Spring

Answer:

Spring supports the following ORM's:

Hibernate
iBatis
JPA (Java Persistence API)
TopLink
JDO (Java Data Objects)
OJB

Q9: Explain the @Controller annotation. ☆☆

Topics: Spring

Answer:

The @Controller annotation indicates that a particular class serves the role of a controller. Spring does not
require you to extend any controller base class or reference the Servlet API.

Q10: What is Spring MVC framework? ☆☆

Topics: Spring

Answer:

The Spring web MVC framework provides model-view-controller architecture and ready components that can
be used to develop flexible and loosely coupled web applications. The MVC pattern results in separating the
different aspects of the application (input logic, business logic, and UI logic), while providing a loose coupling
between these elements.

Q11: How is event handling done in Spring? ☆☆

Topics: Spring

Answer:

Event handling in the ApplicationContext is provided through the ApplicationEvent class and ApplicationListener
interface. So if a bean implements the ApplicationListener, then every time an ApplicationEvent gets published
to the ApplicationContext, that bean is notified.

Q12: What is the purpose of the Core Container module? ☆☆

Topics: Spring

Answer:

Page 3 of 6
FullStack.Cafe - Kill Your Tech Interview

The core container provides the essential functionality of the Spring framework. A primary component of the core
container is the BeanFactory , an implementation of the Factory pattern. The BeanFactory applies the Inversion of
Control (IOC) pattern to separate an application's configuration and dependency specification from the actual
application code.

Q13: What is Application Context? ☆☆

Topics: Spring

Answer:

On the surface, an application context is the same as a bean factory. Both load bean definitions, wire beans
together, and dispense beans upon request. But it also provides:

A means for resolving text messages, including support for internationalization


A generic way to load file resources
Events to beans that are registered as listeners

Q14: What do you mean by Bean wiring ? ☆☆

Topics: Spring

Answer:

The act of creating associations between application components (beans) within the Spring container is referred
to as Bean wiring.

Q15: How to integrate  Java Server Faces (JSF) with Spring? ☆☆

Topics: Spring

Answer:

JSF and Spring do share some of the same features, most noticeably in the area of IOC services. By declaring JSF
managed-beans in the faces-config.xml configuration file, you allow the FacesServlet to instantiate that bean at
startup. Your JSF pages have access to these beans and all of their properties.We can integrate JSF and Spring in
two ways:

DelegatingVariableResolver: Spring comes with a JSF variable resolver that lets you use JSF and Spring
together. The DelegatingVariableResolver will first delegate value lookups to the default resolver of the
underlying JSF implementation, and then to Spring's 'business context' WebApplicationContext. This allows
one to easily inject dependencies into one's JSF-managed beans.

FacesContextUtils: custom VariableResolver works well when mapping one's properties to beans in faces-
config.xml, but at times one may need to grab a bean explicitly. The FacesContextUtils class makes this easy.
It is similar to WebApplicationContextUtils, except that it takes a FacesContext parameter rather than a
ServletContext parameter.

ApplicationContext ctx = FacesContextUtils.getWebApplicationContext(FacesContext.getCurrentInstance());

Q16: What is Spring Security? ☆☆

Page 4 of 6
FullStack.Cafe - Kill Your Tech Interview

Topics: Spring

Answer:

Spring Security is a separate module of the Spring framework that focuses on providing authentication and
authorization methods in Java applications. It also takes care of most of the common security vulnerabilities such
as CSRF attacks.

To use Spring Security in web applications, you can get started with a simple annotation: @EnableWebSecurity.

Q17: What is Spring Boot? ☆☆

Topics: Spring

Answer:

Spring Boot is a project that provides a pre-configured set of frameworks to reduce boilerplate configuration so
that you can have a Spring application up and running with the smallest amount of code.

Q18: What in the world are Spring beans? ☆☆

Topics: Spring

Answer:

Spring beans are just object instances that are managed by the Spring container, namely, they are created and
wired by the framework and put into a "bag of objects" (the container) from where you can get them later.

The "wiring" part there is what dependency injection is all about, what it means is that you can just say "I will
need this thing" and the framework will follow some rules to get you the proper instance.

Q19: Do you need spring-mvc.jar in your classpath or is it part of


spring-core? ☆☆

Topics: Spring

Answer:

The spring-mvc.jar is not part of spring-core, which means that if you want to use Spring MVC framework in
your Java project, you must include spring-mvc.jar in your application's classpath. In a Java web application,
spring-mvc.jar is usually placed inside the /WEB-INF/lib folder.

Q20: What is the DispatcherServlet and what is it used for? ☆☆

Topics: Spring

Answer:

The DispatcherServlet is an implementation of the Front Controller design pattern that handles all incoming web
request to a Spring MVC application. A Front Controller pattern (see Enterprise application design pattern) is a
common pattern in web applications whose job is to receive all request and route it to different components of
the application for actual processing.

Page 5 of 6
FullStack.Cafe - Kill Your Tech Interview

In Spring MVC, DispatcherServlet is used for finding the correct Controller to process a request, which it does
with the help of handler mapping, e.g. the @RequestMapping annotation.

Page 6 of 6

You might also like