Interview Questions And Answers Of Spring In Pdf

interview questions and answers of spring in pdf

File Name: interview questions and answers of spring in .zip
Size: 12836Kb
Published: 22.12.2020

I have tried to collect these spring interview questions which you may face into your next technical interview. For other spring modules, I will share interview questions and answers separately.

I have posted a lot of Spring Tutorials recently. This post will help you get through Spring interview Questions explaining the core concepts in detail. Spring Framework is one of the most popular Java EE frameworks for web applications.

Java Spring Interview Questions

I have posted a lot of Spring Tutorials recently. This post will help you get through Spring interview Questions explaining the core concepts in detail. Spring Framework is one of the most popular Java EE frameworks for web applications.

If you are good in Spring Framework, the chances of getting selected get high. Spring is one of the most widely used Java EE framework. Spring framework can be used in normal java applications also to achieve loose coupling between different components by implementing dependency injection and we can perform cross-cutting tasks such as logging and authentication using spring support for aspect-oriented programming.

Recommended Read : Spring Framework. Dependency Injection design pattern allows us to remove the hard-coded dependencies and make our application loosely coupled, extendable and maintainable. We can implement dependency injection pattern to move the dependency resolution from compile-time to runtime.

Some of the benefits of using Dependency Injection are Separation of Concerns, Boilerplate Code reduction, Configurable components, and easy unit testing. Read more at Dependency Injection Tutorial. We can also use Google Guice for Dependency Injection to automate the process of dependency injection. For better understanding, please read Spring Dependency Injection example where you can learn both the ways with JUnit test case. The post also contains a sample project zip file, that you can download and play around to learn more.

You can read about these features in more detail at Spring 5 Features. Spring WebFlux is the new module introduced in Spring 5. Spring WebFlux is the first step towards the reactive programming model in spring framework. Spring WebFlux is used to create a fully asynchronous and non-blocking application built on the event-loop execution model.

You can read more about it at Spring WebFlux Tutorial. We can install plugins into Eclipse to get all the features of Spring Tool Suite. However, STS comes with Eclipse with some other important kinds of stuff such as Maven support, Templates for creating different types of Spring projects and tc server for better performance with Spring applications.

I like STS because it highlights the Spring components and if you are using AOP pointcuts and advice, then it clearly shows which methods will come under the specific pointcut. So rather than installing everything on our own, I prefer using STS when developing Spring-based applications. Enterprise applications have some common cross-cutting concerns that are applicable to different types of Objects and application modules, such as logging, transaction management, data validation, authentication etc.

In Object Oriented Programming, modularity of application is achieved by Classes whereas in AOP application modularity is achieved by Aspects and they are configured to cut across different classes methods. AOP takes out the direct dependency of cross-cutting tasks from classes that are not possible in normal object-oriented programming.

For example, we can have a separate class for logging but again the classes will have to call these methods for logging the data. Aspect : Aspect is a class that implements cross-cutting concerns, such as transaction management. Aspects can be a normal class configured and then configured in Spring Bean configuration file or we can use Spring AspectJ support to declare a class as Aspect using Aspect annotation.

Advice : Advice is the action taken for a particular join point. In terms of programming, they are methods that gets executed when a specific join point with matching pointcut is reached in the application. You can think of Advices as Spring interceptors or Servlet Filters.

Pointcut : Pointcut are regular expressions that are matched with join points to determine whether advice needs to be executed or not. Pointcut uses different kinds of expressions that are matched with the join points. Spring framework uses the AspectJ pointcut expression language for determining the join points where advice methods will be applied.

Join Point : A join point is a specific point in the application such as method execution, exception handling, changing object variable values etc. In Spring AOP a join point is always the execution of a method. Advice Arguments : We can pass arguments in the advice methods. We can use args expression in the pointcut to be applied to any method that matches the argument pattern. If we use this, then we need to use the same name in the advice method from where the argument type is determined.

These concepts seems confusing at first, but if you go through Spring Aspect, Advice Example then you can easily relate to them.

Inversion of Control IoC is the mechanism to achieve loose-coupling between Objects dependencies. To achieve loose coupling and dynamic binding of the objects at runtime, the objects define their dependencies that are being injected by other assembler objects.

Spring IoC container is the program that injects dependencies into an object and makes it ready for our use. Spring Framework IoC container classes are part of org. Spring IoC container manages the life cycle of Spring Bean, bean scopes and injecting any required dependencies in the bean.

We use Spring Bean configuration file to define all the beans that will be initialized by Spring Context. When we create the instance of Spring ApplicationContext, it reads the spring bean XML file and initializes all of them.

Once the context is initialized, we can use it to get different bean instances. Apart from Spring Bean configuration, this file also contains spring MVC interceptors, view resolvers and other elements to support annotations based configurations. Spring Framework is extendable and we can create our own scopes too, however most of the times we are good with the scopes provided by the framework.

Spring Beans are initialized by Spring Container and all the dependencies are also injected. When the context is destroyed, it also destroys all the initialized beans. This works well in most of the cases but sometimes we want to initialize other resources or do some validation before making our beans ready to use. Spring framework provides support for post-initialization and pre-destroy methods in spring beans. We can do this by two ways — by implementing InitializingBean and DisposableBean interfaces or using init-method and destroy-method attribute in spring bean configurations.

The process of injection spring bean dependencies while initializing it called Spring Bean Wiring. We can use Autowired annotation with fields or methods for autowiring byType.

For this annotation to work, we also need to enable annotation-based configuration in spring bean configuration file. This can be done by context:annotation-config element. For more details about Autowired annotation, please read Spring Autowire Example. Prior to Spring 3. For more details about these options, please read Spring Bean Autowiring. The default scope of Spring bean is singleton, so there will be only one instance per context. That means that all the having a class level variable that any thread can update will lead to inconsistent data.

Hence in default mode spring beans are not thread-safe. However, we can change spring bean scope to request, prototype or session to achieve thread-safety at the cost of performance.

Just like MVC design pattern, Controller is the class that takes care of all the client requests and send them to the configured resources to handle it. In Spring MVC, org. DispatcherServlet is the front controller class that initializes the context based on the spring beans configurations. A Controller class is responsible to handle a different kind of client requests based on the request mappings.

We can create a controller class by using Controller annotation. Component is used to indicate that a class is a component. These classes are used for auto-detection and configured as bean when annotation based configurations are used.

Controller is a specific type of component, used in MVC applications and mostly used with RequestMapping annotation. We can apply this annotation with DAO pattern implementation classes. Service is used to indicate that a class is a Service. Usually, the business facade classes that provide some services are annotated with this. We can use any of the above annotations for a class for auto-detection but different types are provided so that you can easily distinguish the purpose of the annotated classes.

DispatcherServlet is the front controller in the Spring MVC application and it loads the spring bean configuration file and initialize all the beans that are configured. If annotations are enabled, it also scans the packages and configure any bean annotated with Component , Controller , Repository or Service annotations. We can use it to define shared beans that can be used across different spring contexts. ViewResolver implementations are used to resolve the view pages by name.

Usually we configure it in the spring bean configuration file. For example:. InternalResourceViewResolver is one of the implementation of ViewResolver interface and we are providing the view pages directory and suffix location through the bean properties. MultipartResolver interface is used for uploading files — CommonsMultipartResolver and StandardServletMultipartResolver are two implementations provided by spring framework for file uploading.

Once configured, any multipart request will be resolved by the configured MultipartResolver and pass on a wrapped HttpServletRequest. For a complete example, please read Spring Exception Handling Example. This location string can consist of multiple locations separated by any number of commas and spaces.

For example;. We can also define multiple root level spring configurations and load it through context-param. Another option is to use import element in the context configuration file to import other configurations, for example:. ContextLoaderListener is the listener class used to load root context and define spring bean configurations that will be visible to all other contexts.

DispatcherServlet is the Front Controller in the Spring MVC application that takes care of all the incoming requests and delegate it to different controller handler methods. The model can be any Java Bean in the Spring Framework, just like any other MVC framework Spring provides automatic binding of form data to java beans.

We can set model beans as attributes to be used in the view pages. Once the view page is identified, control is given back to the DispatcherServlet controller. DispatcherServlet is responsible for rendering the view and returning the final response to the client.

Spring Interview Questions

Spring is an open source development framework for enterprise Java. The main features of spring may be used for developing applications of Java. Also, extensions for making web applications on top of JavaEE platform can be done. The main goal of spring is to make the development of J2EE development a lot easier to use and promote a programming practice by making use of POJO-based models. Spring is a lightweight framework. This framework is defined as a structure using which we can find the solutions to various technical problems.

This is a summary of some of the most important questions concerning the Spring Framework, that you may be asked to answer in an interview or in an interview.

Spring interview questions and answers

There are a lot of opportunities from many reputed companies in the world. So, You still have an opportunity to move ahead in your career in the Spring certification guide. Do you want to build your career in java spring? Then visit Mindmajix- a global online platform: " Java spring online Training" This course will help you to achieve excellence in this domain.

Spring interview questions

Dependency injection is the concept where you do not create your objects but describe how they should be created, and then expect pre-created objects to be passed in.

Post navigation

Spring is largely a redundancy. Java EE 6 provides what you are likely to need from Spring a standards compliant framework. If you are still doing J2EE development I can understand why you think Spring is the better framework, however. Thanks Thomas you like these spring questions, and thanks for explaining that point some how I completely missed that. Can you add some more Spring framework interview questions , especially from spring mvc part. I am going for spring interview and expecting spring mvc interview questions based on job description.

It is the execution of an aspect.

What is 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.

Она была его помощницей, прекрасным техником лаборатории систем безопасности, выпускницей Массачусетс кого технологического института. Она часто работала с ним допоздна и, единственная из всех сотрудников, нисколько его не боялась. Соши посмотрела на него с укором и сердито спросила: - Какого дьявола вы не отвечаете. Я звонила вам на мобильник. И на пейджер .

Стратмор и его высокопоставленные посетители попадали в шифровалку и уходили незаметно для остальных сотрудников. Лифт спускался на пятьдесят ярдов вниз и затем двигался вбок по укрепленному туннелю еще сто девять ярдов в подземное помещение основного комплекса агентства. Лифт, соединяющий шифровалку с основным зданием, получал питание из главного комплекса, и оно действовало, несмотря на отключение питания шифровалки. Стратмору, разумеется, это было хорошо известно, но даже когда Сьюзан порывалась уйти через главный выход, он не обмолвился об этом ни единым словом.

Top 50 Spring Interview Questions You Must Prepare In 2021