SPRING CORE
N Answer Option
Question Answer Option A Answer Option B Answer Option C
o. D
What is not an advantages of Spring Dependency
framework? It does not support conventional Injection and
1 It is an open-source framework POJO programming rather it has It has layered architecture Inversion of
own mechanism Control
Simplifies JDBC
Identify the true option about Depend It helps in
ency Injection It is a technique to get decoupling
It helps in tight coupling the
2 It helps to store objects in heap. dependencies of any application
application objects.
spring project. objects from
each other.
Which type of dependency injection
3 Spring framework does not support? Construction Injection Setter Injection Interface Injection
Which is not a correct ApplicationContext
ApplicationContext context = new ApplicationContext context = new
implementation of context = new
4 ClassPathXmlApplicationContext FileSystemXmlApplicationContext
ApplicationContext? WebApplicationContext("b
("[Link]"); ("[Link]");
[Link]");
Can IoC container instantiate beans
5 using private constructors? Yes No
Which of the following is not the
feature of IoC? Transaction
6 Object creation Dependency Injection Life Cycle Management
Management
It is possible to provide all beans
By default, the autowiring
Which of the following is true of a particular type from the Typed Maps can be autowired as
fails whenever zero
7 regarding the @Autowired ApplicationContext by adding the long as the expected key type is All of the above.
candidate beans are
annotation? annotation to a field or method String.
available.
that expects an array of that type.
Which statements are true about IoC Modules should
Replacing modules should
(Inversion of Control) ? (multiple Decoupling of the execution of a Each module can focus on what it observe about
8 not affect to other
choice) certain task from implementation. is designed for. what other
modules.
systems do .
Which of the following is not a
9 component of the Spring framework? AOP O/R Integration Spring MVC HTML/JSP
Which is true about Bean scopes in
Spring Framework? Session - a single bean
Prototype - a single bean Singleton - a single bean definition to the lifecycle of
11 definition to any number of object definition to a single object a HTTP Session. Only All of these
instances. instance per Spring IoC container. valid in the context of a
web-aware Spring
ApplicationContext.
What is bean autowiring? Autowiring lets Spring resolve
collaborators otherbeans for your Autowiring
Autowiring helps in wiring a list of bean by inspecting the contents Autowiring injects one injects values in
12
values, allowing duplicates. of the BeanFactory without using bean into another bean. spring factory
<constructor-arg> and <property> beans.
elements.
What is the default scope of a bean
13 in Spring IoC? Abstract Singleton Final Prototype
Which are the different modes of byName ,
byName , byType,
autowiring? byName , byType, destructor and byName , byMethod, constructor byType,
14 constructor and
autodetect and autodetect constructor and
autocorrect
autodetect
What are Bean scopes in Spring Singleton, Prototype,
Framework ? . Request, Session, Page, Singleton, Prototype, Request, Singleton and
15 Session and Global
Application Session and Global Session. Prototype
Session.
Which scope creates a new bean
16 instance each time when requested? Singleton Prototype Session Request
Which configuration can be used for
Dependency Injection? All of the
17 XML Configuration Annotation Configuration Java Based Configuration
mentioned
18 Which of the following is not a valid @Inject annotation is part of Java There is no difference and both @Autowired is a legacy
difference between @Inject and EE 7’s Context and Dependency can be used interchangeably. annotation whereas
@Autowired annotations? Injection framework while @Inject is its latest
@Autowired is the Spring version.
Frameworks own
implementation.
What is request scope? This scopes the
This scopes the bean bean definition
This scopes a bean definition to This scopes the bean definition to
19 definition to HTTP HTTP
an HTTP request. Spring IoC container.
Session. Application/
Global session.
By default a bean is eagerly loaded.
20 FALSE TRUE
What is byType mode of autowiring? Autowiring by
property type.
Spring tries to
Autowiring by property name. Spring first tries to wire match and wire
Default setting which meas no Spring tries to match and wire its using autowire by a property if its
21 autowiring and you should use properties with the beans defined constructor, if it does not type matches
explicit bean reference for wiring. by the same names in the work, Spring tries to with exactly one
configuration file. autowire by byType. of the beans
name in
configuration
file.
Spring is a
Spring is a light weight open Spring is a heavy weight open development
Spring is a proprietary
22 source development framework source development framework framework
framework.
What is spring? for enterprise Java. for enterprise Java. for .Net
applications.
What is Dependency Injection? It is used to
It is a design pattern which It is a technique to get
promote tight
23 implements Inversion of Control It is one of the spring module. dependencies of any
coupling in
for software applications. project.
code.
How do you turn on annotation Add
wiring? Add <annotation- Add <annotation-context- <context:annota
Add <annotation-config /> to bean
24 context:config /> to bean config /> to bean tion-config/> to
configuration.
configuration configuration. bean
configuration.
How can you inject Java Collection in Using list,
Spring? Using lit, set, map or collection Using list, set, props or
25 Using list, set, map or props tag. collection, map
tag. collection tag.
or props tag.
What is no mode of autowiring? Spring first tries to wire Similar to
Default setting which means no using autowire by byType, but type
26 autowiring and you should use Autowiring by property name. constructor, if it does not applies to
explicit bean reference for wiring. work, Spring tries to constructor
autowire by byType. arguments.
By default a bean is lazily loaded.
27 TRUE FALSE
Which class acts as IoC Container?
None of the
28 ServletContext DispatcherServlet ApplicationContext
above
How to use ref keyword in beans? Using setter method and
None of the
29 Using setter method only. Using setter method only. constructor argument
above.
both.
Which of the following stands true for Spring beans are instantiated,
spring beans? Spring beans are managed by assembled, and otherwise Spring beans are simple
30 All of the above.
the Spring IoC container. managed by a Spring IoC POJOs.
container.
How bean life cycle can be
controlled? Using DisposableBean Using All of
31 Using init() only Using InitializingBean class only
class only above
Can we inject value and ref both
32 together in a bean? TRUE FALSE
Which is the way to provide
33 configuration metadata to spring? XML Based configuration file. Annotation based configuration. Java based configuration. All of the above.
What is global-session scope? This scopes the
This scopes a bean definition to This scopes the bean
This scopes the bean definition to bean definition
34 an HTTP Application/ Global definition to HTTP
Spring IoC container. to HTTP
session. request.
Session.
Which is the correct implementation
class of BeanFactory? AdvancedBeanF
35 XmlBeanFactory ClassPathBeanFactory FileSystemBeanFactory
actory
36 What is session scope? This scopes a bean definition to This scopes the bean definition to This scopes the bean This scopes the
bean definition
definition to HTTP to HTTP
an HTTP session. Spring IoC container.
request. Application/
Global session.
How to get object of a service in
37 Spring framework? Using new keyword Using dependency injection
Bean’s naming convention:
38 - starts with a lowercase letter, TRUE FALSE
- and are camel-cased from then on?