40 Latest Interview Questions and Answers On Spring, Spring MVC, and Spring Boot
40 Latest Interview Questions and Answers On Spring, Spring MVC, and Spring Boot
40 Latest Interview Questions and Answers On Spring, Spring MVC, and Spring Boot
com/blog/programming/top-spring-interview-questions-and-
answers
(i) Starts with a class (c1) which has the annotation @Component.
(iii) If yes, then Spring will create a bean for that class (c2) too.
(iv) A connection or autowiring will occur between the two classes (c1 and
c2) using @Autowired annotation and also through the constructor (c2) or
the default case setClass Function (interface the Interface).
5. What is the importance of the annotation @Primary
In Tight Coupling the dependent class takes the responsibility of creating its
dependency. Whereas, in Loose Coupling, we use @Autowired annotation
over the dependency class (or reference) and Spring takes control of
creating the instance and injects the dependency.
The ApplicationContext can be defined in two ways (i) using XML, (ii) using
@Configuration. Once the configuration is done in any of the ways defined
above, the ApplicationContext is created using new
ClassPathXmlApplicationContext. The ClassPathXmlApplicationContext
looks for the XML files, using this is one of the two ways. The other way is
to use AnnotationConfigApplicationContext.
12. How do you perform the same (above question) in Spring Boot?
(i) Singleton: throughout the spring context only one instance is created.
16. What is the difference between the Configuration types XML and
Annotation?
These are the two ways of setting up the configuration, and they perform in
the say way. Though, when the annotation approach is taken very less
amount of code is written and the result would be the same as compared to
the XML approach.
(i) byType
(ii) byName
(iii) Constructor (same as byType, but through constructor)
You may also like: Top 5 Skills That Make You A Sure Shot Programmer
When a transaction (t1) is meant to read the changes that are performed by
another transaction (t2) and provided transaction t2 is not committed yet;
then in such a situation, the transaction t1 is called Dirty Read transaction.
19. List out the new features available in Spring Framework 4.0 and
Spring Framework 5.0?
Spring 4.0 is the first to support Java features. Spring 5.0 has the support
for Reactive Programming and Kotlin.
In FrontController, the Servlet will not get the first request; the first request
would go to FrontController and the request is passed on to the right
servlet. In other words, DispatcherServlet is the front controller which
intercepts all the requests from the client and then dispatches to
appropriate controllers.
(iii) Controllers execute the request and put the data in the model and
return back the view name to the DispatcherServlet.
(iv) DispatcherServlet uses the view name and ViewResolver to map to the
view.
You may also like: Top 55 Java Interview Questions and Answers for
2018
Spring Boot: makes the configuration very easy and automatic using a
feature called Auto Configuration, in which the DispatcherServlet is done by
Spring internally.
Spring JDBC uses methods like update (query), execute (query) and query
(SQL, resultSetExtractor) to interact with the database.
Java Persistence API (JPA) defines the mapping from Java Object to a
Database Table. The procedure to map a Java object to a row in a
database table is defined in JPA. JPA provides a lot of useful annotations,
using which the relationship between classes and tables are defined.
You may also like: Top 30 Interview Questions and Answers on Angular
5
Project Object Model (POM) is an XML formatted file in which all the
configuration for a maven project is defined. The most commonly used tags
in POM.XML are <groupid>, <artifactId>, <version>, <packaging> and a
few more.
This allows the server side to read from data and automatically bind it to a
parameter coming into the method.
39. What is Spring Security?