Interviewer And Interviewee Guide

Sr.Java Web Developer Interview Question:

Do you know bean in Spring and List the different Scopes of Spring bean?

Submitted by: Muhammad
Beans are objects that form the backbone of a Spring application. They are managed by the Spring IoC container. In other words, a bean is an object that is instantiated, assembled, and managed by a Spring IoC container.

There are five Scopes defined in Spring beans.

☛ Singleton: Only one instance of the bean will be created for each container. This is the default scope for the spring beans. While using this scope, make sure spring bean doesn't have shared instance variables otherwise it might lead to data inconsistency issues because it's not thread-safe.
☛ Prototype: A new instance will be created every time the bean is requested.
☛ Request: This is same as prototype scope, however it's meant to be used for web applications. A new instance of the bean will be created for each HTTP request.
☛ Session: A new bean will be created for each HTTP session by the container.
☛ Global-session: This is used to create global session beans for Portlet applications.
Submitted by: Muhammad

Read Online Sr.Java Web Developer Job Interview Questions And Answers
Copyright 2007-2025 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.