Spring Framework MCQs

Spring Framework MCQs

These Spring Framework multiple-choice questions and their answers will help you strengthen your grip on the subject of Spring Framework. You can prepare for an upcoming exam or job interview with these Spring Framework MCQs.
So scroll down and start answering.

1: Which of these resource prefixes could be used?

A.   http:

B.   classpath:

C.   file:

D.   All of these

2: spring-test uses what common convention to allow testing using HTTP session and HTTP request objects?

A.   MVC

B.   Open-closed principle

C.   Mock objects

D.   DAOs

3: True or False? Using Spring's JDBC support forces you to use Oracle.


B.   False

4: Which of the following is NOT a scope available in Spring web applications?

A.   singleton

B.   session

C.   instance

D.   request

5: In the following code: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <bean id="helloWorld" class="com.tutorialspoint.HelloWorld"> <property name="message" value="Hello World!"/> </bean> </beans> The HelloWorld class should have a method called what?

A.   setProperty(String message)

B.   setName(String message)

C.   setMessage(String message)

D.   setValue(String message)

6: How is slf4j commonly used in Spring applications?

A.   as the JDBC provider

B.   as a bean

C.   as the logging framework

7: Is the following valid ? - <map><entry key="a" value="b" /></map>

A.   No

B.   Yes

8: Which of the following is NOT a JDBC statement?

A.   Regular Statement

B.   Callable Statement

C.   Interim Statement

D.   Prepared Statement

9: Which annotation lets you grab the value of an HTTP request header?

A.   @RequestHeader

B.   @Header

C.   @HttpHeader

10: Which one of the following statements is NOT true about MVC pattern?

A.   View represents the data to the user in the desired format, supports interactions with users.

B.   Model represents the business data as well as the "state" of the application

C.   MVC stands for Model, View, and Controller

D.   The controller's main responsibility is to interact with the database like performing CRUD operations.

11: What is one of the major improvements in Spring 3?

A.   more bean scopes are supported

B.   additional lifecycle methods were added

C.   more annotations are supported

12: Which of the following is a synonym for dependency injection?

A.   inversion of control

B.   aspect-oriented programming

C.   pointcut

D.   templates

13: @RequestMapping is part of which part of Spring?

A.   Security

B.   Web MVC

C.   Web

D.   DAO

14: Does Spring support injection of Enum types?

A.   YES

B.   NO

15: Is it possible to set up Spring AOP using XML configuration only (as opposed to annotations)?

A.   No

B.   Yes

16: Which of the following is not a valid method to provide configuration metadata to a Spring Container?

A.   Java-based configuration

B.   XML based configuration file

C.   Annotation-based configuration

D.   By marshalling & unmarshalling the objects

17: True or False? @RequestMapping can be used on an entire class as well as on individual methods.


B.   True

18: How many bean configuration files can you have?

A.   two

B.   as many as you want

C.   only one

19: True or False? Spring Web MVC supports different locales out of the box.

A.   True


20: What type of dependency injection does Spring NOT support?

A.   Setter injection

B.   Constructor injection

C.   Interface injection

21: What if I need a method to be called after bean construction?

A.   delegate to a proxy

B.   use init-method or @PostConstructor

C.   write a custom Handler

22: In AOP, what are the different points where weaving can be applied?

A.   Compile time

B.   Load time

C.   Run time

D.   All of these

23: What is MultipartFile used for?

A.   That doesn't exist

B.   Supporting multi-part HTTP requests

C.   Reading files from disk

D.   Saving files to disk

24: Configuration to declare a JTA transaction manager “<bean id="mgr" class="org.springframework.transaction.jta.JtaTransactionManager" />“ Is this correct?

A.   No

B.   Yes

25: True or False? Spring supports custom bean scopes.

A.   True


26: What are the different modules in Spring framework?

A.   Hibernate Module

B.   Webex module

C.   JDBC abstraction and DAO module

27: What types of transaction management does Spring support?

A.   Programmatic transaction management

B.   Both of these

C.   Declarative transaction management

28: What is AOP?

A.   Aspect oriented programming

B.   None of these

C.   Abstract oriented programming

D.   Advanced oriented programming

29: Can you inject null and empty string values in Spring?

A.   No

B.   Yes

30: What does a bean definition contain?

A.   How to create a bean

B.   All of these

C.   Bean's lifecycle details

D.   Bean's dependencies

31: How are mocks used in Spring?

A.   Spring ignored mocks.

B.   They are an important part of using Spring in tests.

C.   Spring and mocks do not go together well.

32: What is the SpringJUnit4ClassRunner class used for?

A.   Along with @RunWith, starting and stopping a Spring context properly while running JUnit tests

B.   Configuring the Maven Surefire plugin

C.   configuring TestNG

33: What is NOT a way for beans to be defined?

A.   XML configuration file

B.   Java


34: How can you provide configuration metadata to the Spring container?

A.   Java-based configuration

B.   Annotation-based configuration

C.   XML based configuration file

D.   All of these

35: Which of these are types of IOC (dependency injection) ?

A.   None of these

B.   Constructor Injection (e.g. Pico container, Spring etc): Dependencies are provided as constructor parameters.

C.   All of these

D.   Setter Injection (e.g. Spring): Dependencies are assigned through JavaBeans properties (ex: setter methods).

E.   Interface Injection (e.g. Avalon): Injection is done through an interface.

36: Which of the following ORM are supported in Spring

A.   All

B.   OJB

C.   Java Data Objects(JDO)

D.   iBatis

E.   TopLink

37: Spring Security currently supports authentication integration with which of the following technology


B.   All

C.   Form-based authentication

D.   HTTP BASIC authentication headers

E.   HTTP Digest authentication headers

38: True or False? Spring provides an abstraction over JMS.


B.   True

39: True or False? Spring supports lookup via JNDI.


B.   True

40: Which of the following is true when creating a custom login form for applications using Spring Security?

A.   The form action url must match the "login-processing-url" attribute of <form-login> element in security.xml file

B.   The method of the login form must be POST

C.   The name of the username input must corresponds to the values of username-parameter attribute of <form-login> element in security.xml file

D.   All of these

41: What is bean wiring?

A.   consuming a web service

B.   avoiding a cross-cutting concern

C.   publishing objects in a web service

D.   connecting the different beans (components) of an application

42: Transaction MUST follow which of the following properties?

A.   Isolation

B.   Atomicity

C.   Consistency

D.   All of these

43: Which of the following statements are true about Spring Testing Support?

A.   The @ContextConfiguration annotation defines the locations of your configuration files

B.   The TestContext framework of Spring 3 helps simplifying switching between different test framework

C.   All of these

D.   The @Runwith annotation allows you to specify the testing frameworking you would like to use

44: What is the difference between Bean Factory and Application Context?

A.   There is no difference

B.   All of these

C.   Application contexts provide a means for resolving text messages, including support for i18n of those messages.

D.   Application contexts can publish events to beans that are registered as listeners.

E.   Application contexts provide a generic way to load file resources, such as images.

45: Which of the following is NOT a HTTP operation?


B.   GET

C.   PUT


46: What are the supported scopes in Hibernate?

A.   Singleton (default)

B.   All of these

C.   Web (session, request)

D.   Prototype

47: What are the different points where weaving can be applied?

A.   All of these

B.   Classload Time

C.   Compile Time

D.   Runtime

48: The transaction attribute supported by Spring includes:

A.   isolation levels

B.   rollback rules

C.   All of these

D.   propagation behavior

49: Which of the following are Autowire types?

A.   All of these

B.   autodetect

C.   byname, byType

D.   constructor

50: What is the name of the central servlet which is part of Spring?

A.   WebServlet

B.   SpringServlet

C.   IoCServlet

D.   DispatcherServlet