SPRING CORE
SPRING CORE
1. What is not an advantages of Spring framework?
A. It is an open-source framework
B. It does not support conventional POJO programming rather it
has own mechanism
C. It has layered architecture
D. Dependency Injection and Inversion of Control Simplifies
JDBC
B. It does not support conventional POJO programming
rather it has own mechanism
2. Identify the true option about Dependency Injection
A. It helps in tight coupling the application objects.
B. It helps to store objects in heap.
C. It is a technique to get dependencies of any spring project.
D. It helps in decoupling application objects from each other.
D
3. Which type of dependency injection Spring framework does not
support?
A. Construction Injection
B. Setter Injection
C. Interface Injection
C
4. Which is not a correct implementation of ApplicationContext?
A. ApplicationContext context = new
ClassPathXmlApplicationContext("[Link]");
B. ApplicationContext context = new
FileSystemXmlApplicationContext("[Link]");
C. ApplicationContext context = new
WebApplicationContext("[Link]");
C
5. Can IoC container instantiate beans using private constructors?
A. Yes
B. No
A
6. Which of the following is not the feature of IoC?
A. Object creation
B. Dependency Injection
C. Life Cycle Management
D. Transaction Management
D
7. Which of the following is true regarding the @Autowired
annotation?
a. It is possible to provide all beans of a particular type from the
ApplicationContext by adding the annotation to a field or
method that expects an array of that type.
b. Typed Maps can be autowired as long as the expected key
type is String.
c. By default, the autowiring fails whenever zero
candidate beans are available.
d. All of the above.
d
8. Which statements are true about IoC (Inversion of Control) ?
(multiple choice)
a. Decoupling of the execution of a certain task from
implementation.
b. Each module can focus on what it is designed for.
c. Replacing modules should not affect to other modules.
d. Modules should observe about what other systems do .
A , B, C
9. Which of the following is not a component of the Spring
framework?
a. AOP
b. O/R Integration
c. Spring MVC
d. HTML/JSP
D
10. Which is true about Bean scopes in Spring Framework?
a. Prototype - a single bean definition to any number of object
instances.
b. Singleton - a single bean definition to a single object instance
per Spring IoC container.
c. Session - a single bean definition to the lifecycle of a HTTP
Session. Only valid in the context of a web-aware Spring
ApplicationContext."
d. All of these
D
11. "What is bean autowiring?"
a. Autowiring helps in wiring a list of values, allowing
duplicates.
b. Autowiring lets Spring resolve collaborators otherbeans for
your bean by inspecting the contents of the BeanFactory
without using <constructor-arg> and <property> elements.
c. Autowiring injects one bean into another bean.
d. Autowiring injects values in spring factory beans.
B
12. What is the default scope of a bean in Spring IoC?
a. Abstract
b. Singleton
c. Final
B
13. Which are the different modes of autowiring?
a. byName , byType, destructor and autodetect
b. byName , byMethod, constructor and autodetect
c. byName , byType, constructor and autocorrect
d. byName , byType, constructor and autodetect
D
14. What are Bean scopes in Spring Framework ? .
a. Request, Session, Page, Application
b. Singleton, Prototype, Request, Session and Global Session.
c. Singleton, Prototype, Session and Global Session.
d. Singleton and Prototype
B
15. Which scope creates a new bean instance each time when
requested?
a. Singleton
b. Prototype
c. Session
B
16. Which configuration can be used for Dependency Injection?
a. XML Configuration
b. Annotation Configuration
c. Java Based Configuration
d. All of the mentioned
=>D
17. Which of the following is not a valid difference between
@Inject and @Autowired annotations?
a. @Inject annotation is part of Java EE 7’s Context and
Dependency Injection framework while @Autowired is the
Spring Frameworks own implementation.
b. There is no difference and both can be used interchangeably.
c. @Autowired is a legacy annotation whereas @Inject is its
latest version.
C
18. What is request scope?
a. This scopes a bean definition to an HTTP request.
b. This scopes the bean definition to Spring IoC container.
c. This scopes the bean definition to HTTP Session.
d. This scopes the bean definition HTTP Application/ Global
session.
A
19. By default a bean is eagerly loaded.
a. FALSE
b. TRUE
B
20. What is byType mode of autowiring?
a. Default setting which meas no autowiring and you should use
explicit bean reference for wiring.
b. Autowiring by property name. Spring tries to match and wire
its properties with the beans defined by the same names in
the configuration file.
c. Spring first tries to wire using autowire by constructor, if it
does not work, Spring tries to autowire by byType.
d. Autowiring by property type. Spring tries to match and wire a
property if its type matches with exactly one of the beans
name in configuration file.
D
21. "What is spring?"
a. Spring is a light weight open source development framework
for enterprise Java.
b. Spring is a heavy weight open source development
framework for enterprise Java.
c. Spring is a proprietary framework.
d. Spring is a development framework for .Net applications.
A
22. What is Dependency Injection?
a. It is a design pattern which implements Inversion of Control
for software applications.
b. It is one of the spring module.
c. It is a technique to get dependencies of any project.
d. It is used to promote tight coupling in code.
A
23. How do you turn on annotation wiring?
a. Add <annotation-context:config /> to bean configuration
b. Add <annotation-config /> to bean configuration.
c. Add <annotation-context-config /> to bean configuration.
d. Add <context:annotation-config/> to bean configuration.
D
24. How can you inject Java Collection in Spring?
a. Using list, set, map or props tag.
b. Using lit, set, map or collection tag.
c. Using list, set, props or collection tag.
d. Using list, collection, map or props tag.
A
25. What is no mode of autowiring?
a. Default setting which means no autowiring and you should
use explicit bean reference for wiring.
b. Autowiring by property name.
c. Spring first tries to wire using autowire by constructor, if it
does not work, Spring tries to autowire by byType.
d. Similar to byType, but type applies to constructor argument
A
26. By default a bean is lazily loaded.
a. TRUE
b. FALSE
B
27. Which class acts as IoC Container?
a. ServletContext
b. DispatcherServlet
c. ApplicationContext
d. None of the above
C
28. How to use ref keyword in beans?
a. Using setter method only.
b. Using setter method only.
c. Using setter method and constructor argument both.
d. None of the above.
C
29. Which of the following stands true for spring beans?
a. Spring beans are managed by the Spring IoC container.
b. Spring beans are instantiated, assembled, and otherwise
managed by a Spring IoC container.
c. Spring beans are simple POJOs.
d. All of the above.
D
30. How bean life cycle can be controlled?
a. Using init() only
b. Using InitializingBean class only
c. Using DisposableBean class only Using
d. All of above
D
31. Can we inject value and ref both together in a bean?
a. TRUE
b. FALSE
A
32. Which is the way to provide configuration metadata to
spring?
a. XML Based configuration file.
b. Annotation based configuration.
c. Java based configuration.
d. All of the above
D
33. What is global-session scope?
a. This scopes a bean definition to an HTTP Application/
Global session.
b. This scopes the bean definition to Spring IoC container.
c. This scopes the bean definition to HTTP request.
d. This scopes the bean definition to HTTP Session
A
34. Which is the correct implementation class of BeanFactory?
a. XmlBeanFactory
b. ClassPathBeanFactory
c. FileSystemBeanFactory
d. AdvancedBeanFactory
=>A
35. What is session scope?
a. This scopes a bean definition to an HTTP session.
b. This scopes the bean definition to Spring IoC container.
c. This scopes the bean definition to HTTP request.
d. This scopes the bean definition to HTTP Application/ Global
session.
A
36. "How to get object of a service in Spring framework?"
a. Using new keyword
b. Using dependency injection
=> B
37. "Bean’s naming convention:
- starts with a lowercase letter,
- and are camel-cased from then on?"
a. TRUE
b. FALSE
=> A
SPRING DATA JPA
1. Which of the following annotation is used for Is-A mapping?
A. @Inheritance
B. @IsAMapping
C. @InheritanceMapping
A
2. Which annotation is used to link two tables through a relation table?
A. @RelatonTable
B. @JoinTable
C. @LinkTable
B
3. Which of the following is not a mandatory annotation for an entity class?
A. @Entity
B. @Table
C. @Id
B
4. Which of the following annotation is applied on the unique Id of an entity to get its
value generated?
A. @Generator
B. @GeneratedValue
C. @Unique
D. @AutoIncrement
B
5. Which annotation is used to create PK-FK relation beetween two tables?
A. @JoinColumn
B. @ForeignKey
C. @JoinedKey
D. @PrimaryKey
A
6. Which attribute of @OneToMany is used to mark an entity as owned?
A. cascade
B. mappedBy
C. propertyRef
D. eager
B
7. Which of the following Is-A mapping, requires discriminator column?
A. Single Table Mapping
B. Joined Table Mapping
C. Table Per Class Mapping
D. Double Table Mapping
A
8. What is ACID in transactional management?
A. Accurate, Controlled, Isolation, Durability
B. Atomicity, Consistency, Independent, Done
C. Atomicity, Consistency, Isolation, Durability
D. Accurate, Controlled, Independent, Done
C
9. Which of the following database is not supported using JdbcTemplate?
A. MySql
B. PostgresSql
C. NoSql
D. Oracle
C
10. Which of the following class can be used to call Stored Procedures in Spring JDBC?
A. SPHelper
B. JdbcTemplateCall
C. JdbcTemplate
D. SimpleJdbcCall
D
11. Which ORM Spring supports (Multiple choices)?
A. Hibernate
B. iBatis
C. JPA
A,B,C
12. Which of the following class can be used to execute SQL queries in Spring?
A. JDBCHelper
B. JdbcTemplate
C. DBHelper
D. DBTemplate
B
13. What are the ways to access Hibernate by using Spring?
A. Inversion of Control with a Hibernate Template and Callback
B. Extending HibernateDAOSupport and Applying an AOP Interceptor node.
C. Both of above.
D. None of above.
C
14. Which class is used to map a database row to a java object in spring?
A. ResultSet
B. RowMapper
[Link]
[Link]
B
15. What are the types of the transaction management Spring supports?
A. Programmatic transaction management
B. Declarative transaction management
C. Both of above.
D. None of above.
C
16. Spring supports the following ORM’s (apply all):
A. Hibernate
B. iBatis
C. JPA (Java Persistence API)
[Link] and JPA
A,B,C
17. What AOP stands for?
A. Aspect Oriented Programming
B. Any Object Programming
C. Asset Oriented Programming
D. Asset Oriented Protocol
A
18. Which are the modules of Data Access/ integration layer?
A. JDBC, ORM, OXM, JMS, Transactions
B. JDBC, ORM, OXM, JMS
C. JDBC, ORM, Web, Beans
D. JDBC, ORM, OXM, JMS
A
19. What is the JPA equivalent of [Link] file?
A. [Link]
B. [Link]
C. [Link]
B
20. Which method of CrudRepository to returns the entity identified by the given id?
A. T findById(ID primaryKey);
B. T getById(ID primaryKey);
C. T findOne(ID primaryKey);
D. T getOne(ID primaryKey);
C
SPRING WEB MVC
1. What is a DispatcherServlet?
A. Used for Dependency Injection.
B. Handles all the HTTP requests and responses.
C. Used for Spring AOP.
D. Used for transaction management.
B
2. Controller in Spring is .. .
A. a abstract class
B. concrete class
C. final class
D. an interface
D
3. --- is required to load the beans configured in [Link] file?
A. ContextLoader
B. ContextLoaderListener
C. ApplicationContextLoader
B
4. Where do you cannot declare Spring MVC controller? (multiple choise)
A. In a Spring application context XML configuration file
B. Into the [Link] file of the web application
C. Into the java code by using annotations
D. Into the JSP pages
B,D
5. Which of the following layers the @Controller annotation is used in?
A. Business layer.
B. Presentation layer.
C. Service layer.
D. Persistence layer.
B
6. Design pattern implemented by Dispatcher Servlet.
A. jsp tiles
B. front controller
C. none of the mentioned
C
7. Class used to give a class behavior of a Dispatcher Servlet.
A. AbstractController
B. Controller
C. Abstract Class
D. AbstractAction
A
8. Annotation for Controller class?
A. @Before
B. @Controller
C. @After
D. @Servlet
B
9. What is @Controller annotation?
A. The @Controller annotation indicates that a particular class serves the role of a
controller.
B. The @Controller annotation indicates how to control the transaction
management.
C. The @Controller annotation indicates how to control the dependency injection.
D. The @Controller annotation indicates how to control the aspect programming.
A
10. What does @Required annotation mean?
A. This annotation indicates that bean property must be populated by the user.
B. This annotation indicates that bean property is required while saving the bean
data to database.
C. This annotation simply indicates that the affected bean property must be
populated at configuration time, through an explicit property value in a bean
definition or through autowiring.
D. This annotation indicates that bean property is required while serializing the
bean.
C
11. Where do you define DispatcherServlet?
A. In Beans configuration file
B. [Link] file
C. META-INF/[Link]
D. WEB-INF/[Link]
B
12. Which are the modules of Web layer?
A. WebSocket, Servlet, Web, Portlet
B. WebSocket, Servlet, Web-MVC, Web
C. HTML, JSP, WEB, Portlet
D. HTML, Servlet, WEB, Portlet
A
13. What is Spring MVC framework?
A. Spring MVC framework is Model-Value-Class architecture and used to bind
model data with values.
B. The Spring web MVC framework provides model-view-controller architecture
and ready components that can be used to develop flexible and loosely coupled
web applications.
C. Spring MVC framework is used for Transaction management for Web
Applications.
D. Spring MVC framework is used for AOP for Web Applications.
B
14. What is RequestHandledEvent:event?
A. This event is published when the Servlet Context is either initialized or
refreshed.
B. This event is published when the HTTP Request is received.
C. This event is published when the HTTP session is initialized or refreshed.
D. This event is published when the HTTP Request is serviced.
C
15. @RequestMapping annotation is used to map a HTTP request method (GET or
POST) to a specific class or method in the controller which will handle the
respective request?
A. FALSE
B. TRUE
B
16. What annotation is used to map value to the method argument in
[Link]
A. @Map
B. @Param
C. @RequestParam
D. @PathVariable
D
17. In Spring Web App, which of the following acts as a Front Controller?
A. @RestController
B. DispatcherServlet
C. Models
D. Views
B
18. What annotation is used to map a method for PUT request?
A. @PutMapping
B. @PostMapping
C. @Put
D. @Post
A
19. Callback methods provided by HandlerInterceptor to implement.
A. preHandle()
B. postHandle()
C. afterCompletion()
D. All of the mentioned
D
20. Handler method annotation.
A. @Before
B. @Controller
C. @After
D. @RequestMapping
D
21. Annotation which represents cookie values of requests.
A. HttpServletRequest or HttpServleResponse
B. @RequestParam
C. @Cookie
D. None of the mentioned
D
22. To add attributes to the model.
A. Map
B. ModelMap
C. All of the mentioned
D. None of the mentioned
C
23. To notify its completion of session processing.
A. Errors
B. BindingResult
C. SessionStatus
D. one of the mentioned
C
24. Controller Class renders the objects passed by the controller’s handler method.
A. TRUE
B. FALSE
A
25. Parameter used to specify a configuration file.
A. contextConfigLocation
B. contextConfigure
C. contextLocation
D. None of these
A
26. Bean classes pre-registered in the web application context by default.
A. DefaultAnnotationHandlerMapping
B. AnnotationMethodHandlerAdapter
C. All of the mentioned
D. None of the mentioned
C
27. Method arguments that can be used in handler methods using the
@RequestMapping annotation.
A. HttpServletRequest or HttpServleResponse
B. @RequestParam
C. @ModelAttribute
D. All of the mentioned
D
28. Which is not a proper way to access Hibernate using Spring?
A. Extending HibernateDaoSupport and applying an AOP Interceptor
B. Inversion of Control with a HibernateTemplate and Callback.
C. All of the mentioned
D. None of the mentioned
B
29. Which component is used to map a request to a method of a controller?
A. RequestMapping
B. RequestMapper
C. URLMapper
D. RequestResolver
A
30. "What could not return a Spring MVC controller?
A. An absolute path to the view
B. A logical view name
C. A new JstlView
D. void
A
31. ___object is used by a request processing method to check validation failure?
A. ValidationErrors
B. BindingResult
C. ValidationBinding
B
32. Which annotation is required to receive a model object initialized by the request
parameters, in a request processing method?
A. @RequestParam
B. @ModelAttribute
C. @ModelObject
B
33. By default, @RequestMapping gets all the POST Requests.
A. TRUE
B. FALSE
B
34. The @RequestMapping annotation can be applied to the class level only.
A. TRUE
B. FALSE
B
35. To access the binding and validation result for the command object.
A. Errors
B. BindingResult
C. All of the mentioned
D. None of the mentioned
C