YouTube Icon

Interview Questions.

Top 100+ Spring Mvc Framework Interview Questions And Answers - Jun 02, 2020

fluid

Top 100+ Spring Mvc Framework Interview Questions And Answers

Question 1. What Is A Spring?

Answer :

Spring is set to be a framework which allows Java programmer for development of code and it presents IOC box, Dependency Injector, MVC drift and plenty of other APIs for the java programmer.

Question 2. What Are Advices In Spring?

Answer :

It is the execution of an factor. Advice is like making your utility learn a brand new trick. They are usually added at joinpoints.

J2EE Interview Questions
Question 3. What Is The Default Scope Of Bean In Spring Framework?

Answer :

The default scope of bean is Singleton for Spring framework.

Question 4. Name The Types Of Transaction Management That Are Supported By Spring?

Answer :

Transaction management supported by Spring are :

Declarative transaction management.
Programmatic transaction management.
J2EE Tutorial
Question 5. Is Singleton Beans Are Thread Safe In Spring Framework?

Answer :

No, singleton beans are not thread-secure in Spring framework.

Hibernate Interview Questions
Question 6. What Are The Benefits Of Spring Framework?

Answer :

Following are the advantages of Spring framework:

Extensive usage of Components
Reusability
Decoupling
Reduces coding attempt by way of using sample implementations including singleton, factory, service locator and so on.
Removal of leaking connections
Declarative transaction management
Easy to combine with 1/3 birthday celebration tools and technology.
Question 7. What Is Bean Factory?

Answer :

Bean Factory is middle of the spring framework and, it's miles a Lightweight box which masses bean definitions and manages your beans.  Beans are configured using XML file and manipulate singleton described bean. It is likewise liable for lifestyles cycle techniques and injects dependencies. It additionally eliminates adhoc singletons and factories.

Hibernate Tutorial MVC Framework Interview Questions
Question eight. Define Bean Wiring?

Answer :

Bean wiring is the advent of associations among software components which can be among the beans in a selected spring container.

Question 9. What Is Called Spring Mvc?

Answer :

A Spring MVC is a single shared controller example and it's far used to handle request kind controllers, interceptors which run within the IoC container. It also allows multiple Dispatcher Servlets that could share software context interface but no longer magnificence based interface.

Framework7 Interview Questions
Question 10. Why Spring Framework Is Needed?

Answer :

Spring framework is needed because it's miles –

Very Light Weight Container
Framework
IOC
AOP
MVC Framework Tutorial
Question 11. Name The Various Modules Used In Spring Framework?

Answer :

AOP module (Aspect Oriented Programming)
JDBC abstraction and DAO module
The Core box module
MVC framework module
Application context module
O/R mapping integration module (Object/Relational)
Web module
Maven Interview Questions
Question 12. Explain The Rowcallbackhandler In Spring?

Answer :

The RowCallbackHandler is referred to as for each row in ResultSet and is used to study values from the ResultSet.

J2EE Interview Questions
Question thirteen. Define Application Context Module?

Answer :

This is a completely essential module and elements diverse essential services like EJB integration, remoting, JNDI get entry to and scheduling. It transforms spring into a framework. It additionally broadens the idea of BeanFactory through software of lifecycle events, supplying support for internationalization messages and validation.

Framework7 Tutorial
Question 14. Write About Aop Module?

Answer :

AOP module is utilized for developing factors for Spring packages. It also enables help for metadata programming in Spring.

Question 15. What Is A Beanfactory Interface?

Answer :

Bean factory interface is used to offer configuration framework for item advent and primary functionality round item management.

JUnit Interview Questions
Question 16. State The Differences Between Applicationcontext And Beanfactory In Spring?

Answer :

ApplicationContext lets in a couple of config files to exist at the same time as BeanFactory handiest permits one.
ApplicationContext can print events to beans registered as listeners. This function isn't supported through BeanFactory.
ApplicationContext also affords assist for software of lifecycle events, internationalization messages and validation and additionally gives offerings like EJB integration, remoting, JNDI get right of entry to and scheduling. These capabilities too are not supported by using Bean Factory.
Maven Tutorial
Question 17. What Is Auto Wiring?

Answer :

Autowiring is used to construct relationships among the taking part beans. Spring field can routinely clear up collaborators for beans.

Log4j Interview Questions
Question 18. What Are The Different Modes Of Autowiring?

Answer :

Autowiring has five extraordinary modes:

no: no autowire
byName : Autowiring that may be finished with the aid of belongings name
byType : property kind as autowired
constructor: It is much like byType and it's miles property is in constructor
autodetect :  Spring is allowed to pick out autowiring from byType or constructor
Hibernate Interview Questions
Question 19. How To Start Using Spring?

Answer :

Following steps wishes to be done initially the Spring:

Download Spring and its established report from spring’s website.
Create utility context xml to outline beans and its dependencies
Integrate software context xml with internet.Xml
Deploy and Run the utility
JUnit Tutorial
Question 20. What Are The Methods Of Bean Life Cycle?

Answer :

There are  important methods of Bean life cycle:

Setup – called while bean is loaded into box
Teardown – called whilst bean is unloaded into container
Java J2ee Architect Interview Questions
Question 21. What Are The Different Types Of Events Of Listeners?

Answer :

Following are the one-of-a-kind types of events of listeners: 

ContextClosedEvent – This event is known as when the context is closed.

ContextRefreshedEvent – This event is referred to as whilst context is initialized or refreshed
RequestHandledEvent – This occasion is known as while the net context handles request
Question 22. Differentiate Between Singleton And Prototype Bean?

Answer :

Singleton method simplest one bean is described in keeping with item instance while Prototype manner one definition to multiple object instances in Spring.

Log4j Tutorial
Question 23. What Are The Types Of Dependency Injection?

Answer :

Two varieties of dependency injection are supported with the aid of spring framework:

Setter Injection
Constructor Injection
Spring Boot Interview Questions
Question 24. Write About Core Container Module?

Answer :

Core box module is answerable for the simple functionality of the spring framework. The entire Spring framework is constructed with this module as a base.

MVC Framework Interview Questions
Question 25. What Is Aop Module?

Answer :

This AOP module is used for spring enabled utility. Support has been provided AOP alliance to ensure the interoperability between spring and other AOP frameworks.

It instructs spring to add annotations to the source code and inform the way to practice factors.

Spring MVC Framework Tutorial
Question 26. What Is Aop Alliance?

Answer :

AOP alliance is an open-supply assignment that's geared toward promoting adoption of AOP. The AOP alliance’s aim is to outline a not unusual set of additives and interfaces that allows you to enhance interoperability amongst one-of-a-kind AOP implementations.

Spring Batch Interview Questions
Question 27. What Is Called Spring Configuration File?

Answer :

Spring configuration file is an XML report and it carries class records. It also describes how these classes are configured and have interaction with each different.

Framework7 Interview Questions
Question 28. What Are Different Types Of Autowire?

Answer :

There are four distinctive types of Auto cord:

byName
byType
constructor
autodetect
Question 29. What Are The Types Of The Transaction Management That Is Supported By Spring?

Answer :

Following are the sorts of transaction management that has been supported by spring:

declarative
programmatically
Spring Security Interview Questions
Question 30. When Are Declarative And Programmatic Transaction Management Used?

Answer :

When most effective a small quantity of transactional operations is there, it is recommended to apply Programmatic transaction control. But if there may be a big quantity of transactional operations to be taken care of, declarative transaction control is preferred.

Question 31. What Is Ioc?

Answer :

IOC (Inversion of Control sample) is likewise referred to as dependency injection. IOC directs the programmers to depict how to create gadgets alternatively of really developing them. But in this design sample, this control has been given to assembler and assembler will instantiate required elegance if wanted.

Question 32. Write About The Different Types Of Listener Related Events?

Answer :

The one-of-a-kind styles of activities related to listeners are:

ContextRefreshedEvent – This receives called whilst the context is refreshed or initialized.
RequestHandledEvent – This receives known as while the net context is managing a request.
ContextClosedEvent – This receives known as while the context gets closed.
Question 33. What Is An Aspect?

Answer :

Aspect is likewise known as as logging which is required in the course of the application. Logging or factor is a cross slicing capability in an application using AOP.

Maven Interview Questions
Question 34. What Is A Joinpoint?

Answer :

The factor wherein an thing can be brought in the software is referred to as a joinpoint. This factor might be a discipline being changed, a technique being known as or maybe an exception being thrown. At those points, the new component’s code can be delivered to introduce a brand new conduct to the utility.

Aspect code can be inserted at this point into ordinary waft of software to alternate the cutting-edge conduct.

Question 35. What Is Called An Advice?

Answer :

Advice will tell application on new conduct and it's miles the implementation of an aspect. It is inserted into an application on the joinpoint.

Advice is the implementation of an element. It is something like telling your utility of a new conduct. Generally, the advice is inserted into an application at joinpoints.

Question 36. What Is A Pointcut?

Answer :

Pointcut is used to allow in which the advice may be applied.

JUnit Interview Questions
Question 37. What Is Weaving?

Answer :

Weaving is used to create new proxy object by means of making use of factors to target object.

Question 38. What Is Difference Between Singleton And Prototype Bean?

Answer :

Singleton Bean: – Single bean definition to a single item instance per Spring IOC box

Prototype Bean: – Single bean definition to any number of item times in keeping with Spring IOC Container

Question 39. In What Points, Can Weaving Be Applied?

Answer :

Following are the factors where weaving may be implemented:

Compile Time
Class load Time
Runtime
Question 40. What Are The Different Types Of Autoproxying?

Answer :

Following are the distinctive styles of AutoProxying:

BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
Metadata autoproxying
Log4j Interview Questions
Question forty one. How Can Beans Be Made Singleton Or Prototype?

Answer :

The bean tag has an characteristic called ‘singleton’. The bean is singleton if its fee is ‘TRUE’, in any other case the bean is a prototype.

Question 42. What Classes Are Used To Control The Database Connection?

Answer :

Following are the training that are used to manipulate database connection:

Data Source Utils
SmartData Source
AbstractData Source
SingleConnection DataSource
DriverManager DataSource
TransactionAware DataSourceProxy
DataSource  TransactionManager
Java J2ee Architect Interview Questions
Question forty three. Describe About Dao In Spring Framework?

Answer :

DAO is used to provide integration of Java database connectivity and Object relational mapping objects. DAO is spring framework offers connection for JDBC, hibernate, JDO, JPA, Common purchaser interface and Oracle.

Question 44. What Is Autoproxying?

Answer :

Autoproxying is used to create proxy automatically for the spring customers.

It presents following  classes to help this computerized proxy advent:

BeanNameAutoProxyCreator
DefaultAdvisorAutoProxyCreator
Question 45. What Is Metadata Autoproxying?

Answer :

Metadata Autoproxying may be executed inspiring which can be pushed by way of metadata. This is determined with the aid of supply degree attributes and continues metadata in the supply code.

This continues metadata in a single vicinity and particularly used for declarative transaction aid.

Question 46. What Is ‘throws Advice’ In Spring?

Answer :

‘Throws Advice’ outline the behavior when an exception takes place. It is an interface and it has no strategies which want to be carried out.

A class that implements this interface have to have technique with this signature:

Void samplethrow (Throw desk t)
Void samplethrow(Method m, Object[] o, Object target, Throw tablet)
Question forty seven. What Are The Various Editors Used In Spring Work?

Answer :

The various custom editors furnished with the aid of the Spring Framework are:

PropertyEditor
URLEditor
ClassEditor
CustomDateEditor
FileEditor
LocaleEditor
StringArrayPropertyEditor
StringTrimmerEditor
Question forty eight. What Are The Advantages Of Spring Framework?

Answer :

Following are the advantages of spring framework:

Layered Architecture
Enables Plain Old Java Object (POJO) Programming and it enables continuous integration and testability
Dependency Injection and Inversion of Control that simplifies JDBC
Open source framework which can be used for business motive
Question forty nine. How Is Hibernate Accessed Using The Spring Framework?

Answer :

Hibernate may be accessed within the following two ways:

By IOC with a Callback and HibernateTemplate.
By making use of an AOP Interceptor and broadening the HibernateDaoSupport.
Question 50. What Are The Various Channels Supported By Spring 2.Zero?

Answer :

Following are the channels supported by means of spring version 2.Zero:

Pollable Channel
Subscribable Channel
PublishSubscribe Channel
Queue Channel
Priority Channel
Rendezvous Channel
Direct Channel
Executor Channel
Scoped Channel
Question fifty one. Why Is Declarative Transaction Management Preferred In Spring?

Answer :

Declarative transaction control has minimal effect at the software code and, consequently, is an idealistic lightweight field.

Question 52. Explain The Concept Of A Beanfactory?

Answer :

BeanFactory applies the concept of a manufacturing facility pattern that makes use of IOC to split the application’s dependencies and configuration from the actual code.

Question fifty three. What Are The Different Scopes Of Spring Bean?

Answer :

Scopes of spring bean are Singleton, prototype, request, consultation and global consultation.

Question fifty four. What Are All The Ways To Access Hibernate By Using Spring?

Answer :

There are two ways to get entry to hibernate the usage of spring:

Inversion of Control with a Hibernate Template and Callback
Extending HibernateDAOSupport and Applying an AOP Interceptor node.
Question fifty five. What Is Inversion Of Control (ioc)?

Answer :

Inversion of Control (IOC) is likewise referred to as as dependency Injection that is nothingbut a design sample that offers control to the assembler of classes. In trendy, class will instantiate another elegance if required.

But in this design sample, this manage has been to given to assembler and assembler will instantiate required magnificence if wanted.

Question fifty six. Write The Benefits Of Using Ioc?

Answer :

The foremost advantages of dependency injection or IOC are that it reduces the quantity of coding required for the utility. This lets in the checking out of the software to be done quickly and easily as no JNDI research mechanism or singletons are required. IOC boxes additionally help lazy loading and keen installation of services.

Question fifty seven. What Is Inner Bean? What Is The Drawback Of Inner Bean?

Answer :

If a bean detail is directly embedded in a belongings tag at the same time as wiring beans, then the bean is called Inner Bean. Its drawback is that it can't be reprocessed.

Question 58. What Are The Different Types Of Injection In Spring?

Answer :

There are 3 sorts of Injection in spring:

Setter Injection
Constructor Injection
Getter or Method Injection
Question fifty nine. What Are The Types Of Advice?

Answer :

There are five types of Advice:

Before Advice
After returning recommendation
After throwing advice
Finally advice
Around advice
Question 60. What Is Called Preparedstatementcreator?

Answer :

PreparedStatementCreator is one of the maximum normally used interfaces for writing information to the database. CreatePreparedStatement() is a way that may be used to create and return PreparedStatement from the Connection argument, and exception handling is automatically looked after. When this interface is implemented, a one of a kind interface SqlProvider also can be carried out which has a way called getSql(). This method is useful for providing square strings to the JdbcTemplate. It does not cope with SQLExceptions.

Question sixty one. What Is Sqlprovider?

Answer :

SQLProvider has only one method known as getSql()and it's miles applied the usage of PreparedStatementCreator implementers. It is specifically used for debugging.

Question sixty two. Write About Batchpreparedstatementsetter?

Answer :

BatchPreparedStatementSetter is used to replace extra than a unmarried row in one pass, they could use BatchPreparedStatementSetter. This interface gives  methods they're

setValues( PreparedStatement ps, int i) throws SOL exception
int getBatchSize
Question sixty three. What Is The Better Method Of Using Jdbc In Spring?

Answer :

If JDBC is used with the template elegance referred to as JdbcTemplate, it gives a higher overall performance.

Question 64. Explain The Advantages Of Using Dao Module?

Answer :

The database code may be saved clean and easy via using the DAO module. This enables in preventing troubles that rise due to negative coping with of closures of database sources. Also, the DAO module makes use of the AOP module to allow gadgets within the Spring software to apply transaction management services.

Question sixty five. Name The Significant Applicationcontext Implementations Used In The Spring Framework?

Answer :

They are:

ClassPathXmlApplicationContext
FileSystemXmlApplicationContext
XmlWebApplicationContext
Question 66. What Are Orm Integration Modules?

Answer :

Object/relational mapping (ORM) device is supported by Spring over instantly JDBC by way of imposing the ORM module. Spring can be a part of numerous vital ORM frameworks, which includes JDO, iBATIS SQL Maps and Hibernate.

Question sixty seven. Mention And Explain The Types Of Advice In Spring?

Answer :

Types of recommendation are:

Before advice: Advice that is performed prior to a joinpoint is called the ‘before recommendation’.
After returning advice: Advice this is executed after the regular of entirety of a joinpoint is called the ‘after returning recommendation’.
After throwing recommendation: Advice this is finished best if a method exits abnormally by using throwing an exception, is referred to as the ‘after throwing recommendation’.
After (finally) advice: Advice that is accomplished regardless of how a joinpoint exits is called ‘after finally advice’.
Around advice: Advice that borders a joinpoint, as an example, a way invocation, is referred to as an ‘around recommendation’. This may be used to perform special sports before and after the invocation of technique.
Question sixty eight. What Is The Web Module?

Answer :

The web module enables the introduction of a web utility with out XML. The net.Xml report wishes to be configured for the usage of the web module.

Question 69. What Is Dataaccessexception?

Answer :

DataAccessException is a RuntimeException. It is an Unchecked Exception. The user cannot be forced to address these sorts of exceptions.

Question 70. What Is Xmlbeanfactory?

Answer :

Spring consists of several applications of Bean manufacturing facility. Out of those, org.Springframework.Beans.Factory.Xml.XmlBeanFactory is a completely important one. It loads the beans on the basis of the definitions saved in an XML record. For the introduction of an XmlBeanFactory, a java.Io.InputStream is handed to the constructor. The InputStream gives the XML to the manufacturing unit. For instance, for retrieval of the bean, the getBean() approach is referred to as by way of passing the call of the favored bean.

Question 71. Name The Exception Class Which Is Connected To The Exceptions Thrown By The Applications?

Answer :

It is the DataAccessException given by using org.Springframework.Dao.DataAccessException

Question seventy two. Mention The Types Of Loc (dependency Injection)?

Answer :

The exclusive sorts of loC are: –

Setter Injection: With the help of JavaBeans houses.
Constructor Injection: Dependencies are given within the form of constructor parameters.
Interface Injection: With the help of an interface, an Injection is done.
Out of these 3, simplest creation and setter are being used in Spring.

Question 73. What Are The Important Beans Lifecycle Methods?

Answer :

All in all,  bean lifecycle strategies are there. The first approach is the setup method that is called all through the loading of the bean into the box. The second is when the bean is unloaded from the container, and this method is known as the teardown.

Question 74. What Is A Target?

Answer :

A goal is the class that is counseled. This class can both be a category to which we need to feature a unique behavior to or a third party elegance. The target class is loose to center on its principal situation using the AOP standards, regardless of any advice this is being carried out.

Question 75. Explain The Term Proxy?

Answer :

The term proxy refers to an object that is produced the application of an advice to the goal object.

Question seventy six. What Is Cross Cutting Concern And Concern In Spring Aop?

Answer :

Cross reducing difficulty:  It is a problem that is relevant at some stage in the application and it affects the complete software. E.G Security, logging and facts switch are the concerns which might be needed in almost each module of an utility.

Concern: Concern is a behavior that we want to have in a module of an utility. Issues in which we're interested defines our subject.




CFG