MCQs > IT & Programming > Spring Framework MCQs > Basic Spring Framework MCQs

Basic Spring Framework MCQ

1. What property can be used to set the active Spring profiles

Answer

Correct Answer: Spring.profiles.active

Note: This Question is unanswered, help us to find answer for this one

2. What interface can be specified as a parameter in a controller method signature to handle file uploads?

Answer

Correct Answer: MultipartFile

Note: This Question is unanswered, help us to find answer for this one

3. How can you access the application context in a Spring integration test?

Answer

Correct Answer: Test classes can implement the ApplicationContextAware interface or autowire the ApplicationContext.

Note: This Question is unanswered, help us to find answer for this one

4. What is the output from invoking this Actuator endpoint in an unmodified Spring Boot application generated using Spring Intializr? /shutdown

Answer

Correct Answer: The request would fail because the endpoint is disabled by default.

Note: This Question is unanswered, help us to find answer for this one

5. What methods does the Pointcut expression below reference? execution(* setter*(..))

Answer

Correct Answer: Any method with a name that begins with String

Note: This Question is unanswered, help us to find answer for this one

6. What pattern does Spring MVC implement to delegate request processing to controllers?

Answer

Correct Answer: Front Controller

Note: This Question is unanswered, help us to find answer for this one

7. How might you map an incoming request to a controller method?

Answer

Correct Answer: Annotate a controller method with @RequestMapping, or a HTTP verb-specific annotation with a String URI pattern parameter (and other params as needed), which is supported through a RequestMappingHandlerMapping/Adapter.

Note: This Question is unanswered, help us to find answer for this one

8. What is a security context?

Answer

Correct Answer: The security context includes details of the principal currently using the app, which is stored by default in a ThreadLocal in an Authentication object.

Note: This Question is unanswered, help us to find answer for this one

9. Assuming no additional configuration is provided, what is the first selection criteria Spring uses to choose a bean when autowiring a property?

Answer

Correct Answer: Bean name

Note: This Question is unanswered, help us to find answer for this one

10. Assuming username and password authentication is in place, what method on the Authentication object can be used to obtain the username?

Answer

Correct Answer: GetPrincipal

Note: This Question is unanswered, help us to find answer for this one

11. What is Spring AOP?

Answer

Correct Answer: Aspect-Oriented Programming enables the modularization of cross-cutting concerns so that repeated boilerplate logic, such as logging code, does not pollute business logic.

Note: This Question is unanswered, help us to find answer for this one

12. What is the purpose of a web application context?

Answer

Correct Answer: It provides configuration for a web application that is read-only while running. Also, it adds a getServletContext() method and defines an attribute name to which the root context must be bound in the bootstrap process.

Note: This Question is unanswered, help us to find answer for this one

13. To register a custom filter that applies only to certain URL patterns, you should remove the _ annotation from the filter class and register a @Bean of type _ in Spring @Configuration.

Answer

Correct Answer: @Component; FilterRegistrationBean

Note: This Question is unanswered, help us to find answer for this one

14. How does the transaction propagation setting impact the behavior of transactions?

Answer

Correct Answer: It enforces that a logical transaction scope is created for each method that determines rollback-only status, with an outer transaction scope being logically independent from the inner transaction scope.

Note: This Question is unanswered, help us to find answer for this one

15. What is the difference between a JAR and a WAR distribution in Spring Boot?

Answer

Correct Answer: Spring Boot can create a self-executable JAR file that contains all the dependencies and an embedded Servlet container. A WAR file has to be deployed to an existing web container such as Tomcat.

Note: This Question is unanswered, help us to find answer for this one

16. What is a Spring bean uniquely identified?

Answer

Correct Answer: A unique String name

Note: This Question is unanswered, help us to find answer for this one

17. What Spring Boot property is used to set the logging level for the entire application in the application.properties file?

Answer

Correct Answer: Logging.level.root

Note: This Question is unanswered, help us to find answer for this one

18. Which property is given precedence by Spring?

Answer

Correct Answer: Profile-specific application-{profile}.properties files

Note: This Question is unanswered, help us to find answer for this one

19. What is a bean in the context of Spring?

Answer

Correct Answer: A managed dependency defined by configuration metadata that can be injected into downstream classes

Note: This Question is unanswered, help us to find answer for this one

20. How do you inject a dependency into a Spring bean?

Answer

Correct Answer: Any of these answers

Note: This Question is unanswered, help us to find answer for this one

21. Modularization of a concern that cuts across multiple classes is known as a(n)____.

Answer

Correct Answer: Aspect

Note: This Question is unanswered, help us to find answer for this one

22. What is a transaction in the context of Spring Data?

Answer

Correct Answer: A sequence of actions representing a single unit of work managed as a single operation that can be either committed or rolled back

Note: This Question is unanswered, help us to find answer for this one

23. Which are valid steps to take to enable JPA in Spring Boot?

Answer

Correct Answer: Add an @EnableJpaRepositories annotation to your configuration class and create a Spring Data Repository.

Note: This Question is unanswered, help us to find answer for this one

24. What is Spring Boot autoconfiguration?

Answer

Correct Answer: It's an opinionated, intelligent method of introspecting an app to configure beans that are likely to be needed. This configuration can be overridden over time with manual configuration.

Note: This Question is unanswered, help us to find answer for this one

25. What is the DispatcherServlet and what is its function?

Answer

Correct Answer: It is a servlet that dispatches HTTP requests to registered handlers/controllers for processing.

Note: This Question is unanswered, help us to find answer for this one

26. What is the purpose of the @RequestBody annotation?

Answer

Correct Answer: To indicate whether an annotated handler method parameter should be bound to the web request body, which is converted by an HttpMessageConverter

Note: This Question is unanswered, help us to find answer for this one

27. How are authentication and authorization different?

Answer

Correct Answer: Authentication is validating that users are who they claim to be. Authorization is granting access to specific resources and functions.

Note: This Question is unanswered, help us to find answer for this one

28. What is the purpose of the @ContextConfiguration annotation in a JUnit Test?

Answer

Correct Answer: It defines metadata at the class-level to determine how to load or configure an ApplicationContext in Spring integration tests.

Note: This Question is unanswered, help us to find answer for this one

29. What value does Spring Boot Actuator provide?

Answer

Correct Answer: It helps monitor and manage a Spring Boot application by providing endpoints such as health checks, auditing, metrics gathering, and HTTP tracing.

Note: This Question is unanswered, help us to find answer for this one

30. What is the delegating filter proxy?

Answer

Correct Answer: It's the servlet filter proxy delegating to a filter bean specified in web.xml. All calls to the filter proxy will be delegated to that servlet filter bean.

Note: This Question is unanswered, help us to find answer for this one

31. How does Spring Data facilitate queries against a datastore?

Answer

Correct Answer: Queries are derived from the signatures of methods on a Spring Data repository that contain keywords in their name for constructing the query logic.

Note: This Question is unanswered, help us to find answer for this one

32. What does @SpringBootApplication do?

Answer

Correct Answer: This compound annotation applies the @Bootable, @Springify, and @StandardConfig annotations that launch a CLI tool after launching the Spring Boot WAR file that will guide you through a series of prompts to set up your app.

Note: This Question is unanswered, help us to find answer for this one

33. What is component scanning?

Answer

Correct Answer: Feature that scans packages for classes with specific annotations and, when found, creates their bean definitions within the IoC container

Note: This Question is unanswered, help us to find answer for this one

34. What is the purpose of the Spring IoC (Inversion of Control) container?

Answer

Correct Answer: It instantiates and configures objects, supplied at runtime, to classes that define them as a dependency.

Note: This Question is unanswered, help us to find answer for this one

35. What is the name of the central servlet that dispatches requests to controllers?

Answer

Correct Answer: DispatcherServlet

Note: This Question is unanswered, help us to find answer for this one

36. How are mocking frameworks such as Mockito used with Spring?

Answer

Correct Answer: Mockito can use annotations or factory methods to create mock objects that may be injected into tests in place of dependencies. The behavior of mocks can be explicitly configured.

Note: This Question is unanswered, help us to find answer for this one

37. What is the purpose of the @ResponseBody annotation?

Answer

Correct Answer: To indicate whether a handler method return value should be bound to the web response body in servlet environments

Note: This Question is unanswered, help us to find answer for this one

38. Which property can be used to change the port of a Spring application?

Answer

Correct Answer: Server.port

Note: This Question is unanswered, help us to find answer for this one

39. What happens when a class is annotated with the @Controller annotation?

Answer

Correct Answer: A controller bean definition is defined in the servlet's WebApplicationContext. The class is marked as a web component, and you can map requests to controller methods.

Note: This Question is unanswered, help us to find answer for this one

40. What is a RESTful web service?

Answer

Correct Answer: Representational State Transfer an architectural style for creating web services that includes client-server architecture, statelessness, cacheability, a layered system, and a uniform interface.

Note: This Question is unanswered, help us to find answer for this one

41. What is dependency injection?

Answer

Correct Answer: A method by which objects define dependencies they need as abstractions that allows the framework to instantiate and configure them in a central location at runtime.

Note: This Question is unanswered, help us to find answer for this one

42. What is the purpose of the @Lazy annotation and why would you use it?

Answer

Correct Answer: It can be applied to a bean so that the bean is not created and injected until it is needed. It can help speed up startup time for your application.

Note: This Question is unanswered, help us to find answer for this one

43. Which annotation can be used within Spring Security to apply method level security?

Answer

Correct Answer: @Secured

Note: This Question is unanswered, help us to find answer for this one

44. What is the root interface for accessing a Spring bean container?

Answer

Correct Answer: BeanFactory

Note: This Question is unanswered, help us to find answer for this one

45. What is the function of the @Transactional annotation at the class level?

Answer

Correct Answer: It creates a proxy that implements the same interface(s) as the annotated class, allowing Spring to inject behaviors before, after, or around method calls into the object being proxied.

Note: This Question is unanswered, help us to find answer for this one

46. In what order do the @PostConstruct annotated method, the init-method parameter method on beans and the afterPropertiesSet() method execute?

Answer

Correct Answer: 1. @PostConstruct 2. afterPropertiesSet() 3. init-method

Note: This Question is unanswered, help us to find answer for this one

47. Which of these is not a valid method on the JoinPoint interface?

Answer

Correct Answer: GetExceptions()

Note: This Question is unanswered, help us to find answer for this one

48. How are JDK Dynamic proxies and CGLIB proxies used in Spring?

Answer

Correct Answer: JDK Dynamic proxy can proxy only interface, so it is used if the target implements at least one interface. A CGLIB proxy can create a proxy by subclassing and is used if the target does not implement an interface.

Note: This Question is unanswered, help us to find answer for this one

49. The process of linking aspects with other objects to create an advised object is called

Answer

Correct Answer: Weaving

Note: This Question is unanswered, help us to find answer for this one

50. What is SpEL and how is it used in Spring?

Answer

Correct Answer: SpEL(Spring Expression Language) supports boolean and relational operators and regular expressions, and is used for querying a graph of objects at runtime.

Note: This Question is unanswered, help us to find answer for this one

51. How are Spring Data repositories implemented by Spring at runtime?

Answer

Correct Answer: A JDK proxy instance is created, which backs the repository interface, and a MethodInterceptor intercepts calls to the instance and routes as required.

Note: This Question is unanswered, help us to find answer for this one

52. What does a ViewResolver do?

Answer

Correct Answer: It generates a view by mapping a logical view name returned by a controller method to a view technology.

Note: This Question is unanswered, help us to find answer for this one

53. Which of these is a valid Advice annotation?

Answer

Correct Answer: @AfterReturning

Note: This Question is unanswered, help us to find answer for this one

54. How is a resource defined in the context of a REST service?

Answer

Correct Answer: It is an abstract concept that represents a typed object, data, relationships, and a set of methods that operate on it that is accessed via a URI.

Note: This Question is unanswered, help us to find answer for this one

55. How filters are used in Spring Web?

Answer

Correct Answer: Filters are called before a request hits the DispatcherServlet. They allow for interception-style, chained processing of web requests for security, timeouts, and other purposes.

Note: This Question is unanswered, help us to find answer for this one

56. Which of these is correct when creating an ApplicationContext?

Answer

Correct Answer: ApplicationContext ctx = new ClasspathXmlApplicationContext("one.ctx","two.ctx");

Note: This Question is unanswered, help us to find answer for this one

57. When detecting a Device device in a @Controller in Spring MVC, which of these is NOT supported?

Answer

Correct Answer: device.isDesktop()

Note: This Question is unanswered, help us to find answer for this one

58. Which the following statements is true about Spring validation?

Answer

Correct Answer: Custom validation can be implemented through Spring's support of JSR-303, the Bean Validation API

Note: This Question is unanswered, help us to find answer for this one

59. How can you find out about the current content when an aspect is invoked?

Answer

Correct Answer: Through Joinpoint

Note: This Question is unanswered, help us to find answer for this one

60. Which one of the following statements is true about the following configuration in web.xml: <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class> org.springframework.web.filter.DelegatingFilterProxy </filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/myapplication/*</url-pattern> </filter-mapping>

Answer

Correct Answer: The <filter-name> value for the DelegatingFilterProxy must be "springSecurityFilterChain".

Note: This Question is unanswered, help us to find answer for this one

61. When are proxies generated in the Spring lifecycle?

Answer

Correct Answer: Bean Post Processing

Note: This Question is unanswered, help us to find answer for this one

62. Which of the following is NOT a filter type in <context:component-scan> element?

Answer

Correct Answer: bean

Note: This Question is unanswered, help us to find answer for this one

63. Which of the following development styles are supported by Spring WS?

Answer

Correct Answer: Contract First but NOT Contract Last

Note: This Question is unanswered, help us to find answer for this one

64. Which of the following is a VALID way of implementing Programmatic Transactions in Spring

Answer

Correct Answer: Using PlatformTransactionManager

Note: This Question is unanswered, help us to find answer for this one

65. Spring MVC annotation can be used to perform:

Answer

Correct Answer: Redirect URL

Note: This Question is unanswered, help us to find answer for this one

66. A SQLProvider has one method called?

Answer

Correct Answer: getSql()

Note: This Question is unanswered, help us to find answer for this one

67. Which of the following implementation provides the mechanism for JSF and Spring integration?

Answer

Correct Answer: DelegatingVariableResolver

Note: This Question is unanswered, help us to find answer for this one

68. What is the @WebAppConfiguration annotation used for?

Answer

Correct Answer: In combination with @ContextConfiguration, used to declare a test as a "web test"

Note: This Question is unanswered, help us to find answer for this one

69. What are the features of the XML <context: namespace?

Answer

Correct Answer: @Autowired annotation enabling and @Component annotation scanning

Note: This Question is unanswered, help us to find answer for this one

70. Which of the following is NOT a feature of Spring Security 3.x

Answer

Correct Answer: Support for limiting number of user sessions

Note: This Question is unanswered, help us to find answer for this one

71. Which of the following is a valid usage of Method Injection in spring?

Answer

Correct Answer: To inject a non-singleton bean inside a singleton bean

Note: This Question is unanswered, help us to find answer for this one

72. Which of the following is NOT an advantage of SimpleJdbcTemplate?

Answer

Correct Answer: Converts standard JDBC SQLExceptions into checked exceptions

Note: This Question is unanswered, help us to find answer for this one

73. Which of the following scopes is valid ONLY in the context of a web-aware Spring ApplicationContext?

Answer

Correct Answer: global-session

Note: This Question is unanswered, help us to find answer for this one

74. Which one of the following statements is NOT true about <mvc: annotation-driven>:

Answer

Correct Answer: It enables the support of annotation configuration for transactions.

Note: This Question is unanswered, help us to find answer for this one

75. Which one of the following statements is NOT true about Spring Web Flow states?

Answer

Correct Answer: The End state is the last stop. Each flow can only have one end state.

Note: This Question is unanswered, help us to find answer for this one

76. Which one of the following statements is true about the propagation attributes that can be defined in @Transactional annotations?

Answer

Correct Answer: MANDATORY: There must be a transaction; otherwise, throw an exception.

Note: This Question is unanswered, help us to find answer for this one

77. <concurrency-control> element can be used for which of the following purposes?

Answer

Correct Answer: To limit number of user sessions

Note: This Question is unanswered, help us to find answer for this one

78. Which of the following is a common cross-cutting concern?

Answer

Correct Answer: logging

Note: This Question is unanswered, help us to find answer for this one

79. Which of the following is the most commonly used view resolver for integrating JSPs with Spring?

Answer

Correct Answer: Both InternalResourceViewResolver and ResourceBundleViewResolver

Note: This Question is unanswered, help us to find answer for this one

80. Which one of the following is NOT true about the followng code: @Controller @RequestMapping("/reservationForm") @SessionAttributes("reservation") public class ReservationFormController { ... @RequestMapping(method = RequestMethod.POST) public String submitForm(@ModelAttribute("reservation") Reservation reservation, BindingResult result) { ... return "redirect:reservationSuccess"; } ... }

Answer

Correct Answer: The BindingResult object is used to map the user request to the controller method.

Note: This Question is unanswered, help us to find answer for this one

81. Which one of the following is NOT true about Spring MVC View resolver

Answer

Correct Answer: BeanNameViewResolver: Finds an implementation of View that’s registered as a <bean> whose class is the same as the logical view name.

Note: This Question is unanswered, help us to find answer for this one

82. Which of the following statements is NOT true when defining the <intercept-url> elements in security.xml?

Answer

Correct Answer: When defining the <intercept-url> elements the sequence doesn't matter

Note: This Question is unanswered, help us to find answer for this one

83. Which one of the following is NOT true about HibernateDaoSupport Class

Answer

Correct Answer: HibernateDaoSupport class, has a commit() method which can commit the transaction

Note: This Question is unanswered, help us to find answer for this one

84. Are Spring singleton beans thread-safe?

Answer

Correct Answer: No

Note: This Question is unanswered, help us to find answer for this one

85. Spring - WS Core is NOT dependent on which of the following modules?

Answer

Correct Answer: Spring WS Security

Note: This Question is unanswered, help us to find answer for this one

86. Which of the following best describes Spring Batch?

Answer

Correct Answer: Spring Batch provides classes and APIs to read/write resources, transaction management, job processing statistics, job restart and partitioning techniques to process high-volume of data

Note: This Question is unanswered, help us to find answer for this one

87. True or False? @PathVariable is used on classes to indicate they will be used as handlers if a variable is found.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

88. In Spring and Hibernate integration, which is the correct implementation of the Session Factory?

Answer

Correct Answer: LocalSessionFactoryBean

Note: This Question is unanswered, help us to find answer for this one

89. In transactions and exception management, what is the default rollback policy?

Answer

Correct Answer: Rollback for a RuntimeException

Note: This Question is unanswered, help us to find answer for this one

90. Which of the following annotation enables default data conversion in Spring Web MVC?

Answer

Correct Answer: @InitBinder

Note: This Question is unanswered, help us to find answer for this one

91. Which of the following is incorrect?

Answer

Correct Answer: ApplicationContext does NOT publish events to beans that are registered as listeners whereas BeanFactory published events to registered beans

Note: This Question is unanswered, help us to find answer for this one

92. Which of the following is a VALID Spring form taglib declaration?

Answer

Correct Answer: <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

Note: This Question is unanswered, help us to find answer for this one

93. A RowCallbackHandler has one method called?

Answer

Correct Answer: processRow(ResultSet)

Note: This Question is unanswered, help us to find answer for this one

94. Which of the following are valid approaches for integration Struts with Spring?

Answer

Correct Answer: Any of the given approach can be used to integrate the two

Note: This Question is unanswered, help us to find answer for this one

95. How can we create a PreparedStatementCreator?

Answer

Correct Answer: createPreparedStatement(Connection)

Note: This Question is unanswered, help us to find answer for this one

96. Which of the following is FIRST step in user authentication process?

Answer

Correct Answer: The username and password are obtained and combined into an instance of UsernamePasswordAuthenticationToken

Note: This Question is unanswered, help us to find answer for this one

97. If you don't want a method to be enlisted in a transaction at all, what type of attribute can be used?

Answer

Correct Answer: @Transactional(propagation = Propagation.NEVER)

Note: This Question is unanswered, help us to find answer for this one

98. What is the purpose of the SessionStatus.setComplete()?

Answer

Correct Answer: Expires the session Data of a controller.

Note: This Question is unanswered, help us to find answer for this one

99. What is the @BeforeTransaction annotation used for?

Answer

Correct Answer: as part of testing, making sure some code is executed before the transaction is started

Note: This Question is unanswered, help us to find answer for this one

100. Which of the following best describes the utility of @RunWith(SpringJUnit4ClassRunner.class)?

Answer

Correct Answer: This annotation means that tests are going to be able to get hold of instantiated beans as defined in the Spring context files

Note: This Question is unanswered, help us to find answer for this one

101. Which of the following identify the application-wide permissions available to a principal?

Answer

Correct Answer: GrantedAuthority

Note: This Question is unanswered, help us to find answer for this one

102. How do you specify the incoming HTTP content-type?

Answer

Correct Answer: Use the 'consumes' attribute of @RequestMapping

Note: This Question is unanswered, help us to find answer for this one

103. How do you specify outgoing HTTP content-type?

Answer

Correct Answer: Use the 'produces' attribute of @RequestMapping

Note: This Question is unanswered, help us to find answer for this one

104. Which of the following is NOT true about Spring transaction management?

Answer

Correct Answer: The Spring Framework support propagation of transaction contexts across remote calls

Note: This Question is unanswered, help us to find answer for this one

105. Which one of the following statements is NOT true about @Transactional attributes

Answer

Correct Answer: the default value of readOnly attribute is true

Note: This Question is unanswered, help us to find answer for this one

106. BeanFactory is a popular way to wire beans in Spring, which is a correct way of creating a BeanFactory?

Answer

Correct Answer: BeanFactory factory = new XmlBeanFactory(new FileInputStream(“beans.xml”));

Note: This Question is unanswered, help us to find answer for this one

107. What are benefits of transactions for Hibernate?

Answer

Correct Answer: Read only transactions prevent Hibernate from flushing session

Note: This Question is unanswered, help us to find answer for this one

108. Which one of the following statements is NOT true about the following code: @Service("jpaStudentService") @Repository @Transactional public class StudentServiceImpl implements StudentService { private Log log = LogFactory.getLog(StudentServiceImpl.class); @PersistenceContext private EntityManager em; // Other code omitted }

Answer

Correct Answer: @PersistenceContext is a Spring annotation which instructs Spring to inject a SessionFactory

Note: This Question is unanswered, help us to find answer for this one

109. Which of the following utility classes provides functionality to set a non-public field or invoke a non-public setter method when testing application code?

Answer

Correct Answer: ReflectionTestUtils

Note: This Question is unanswered, help us to find answer for this one

110. Which one of the following statements is NOT true about the Application Context.

Answer

Correct Answer: ApplicationContext provides dependency Injection services and AOP service, but NOT transaction services.

Note: This Question is unanswered, help us to find answer for this one

111. Which view technologies does Spring Web MVC NOT support out of the box?

Answer

Correct Answer: Hibernate

Note: This Question is unanswered, help us to find answer for this one

112. Which of the following is NOT a valid spring framework module?

Answer

Correct Answer: Spring Bean Factory

Note: This Question is unanswered, help us to find answer for this one

113. Which of the following is NOT a way to use Spring Web MVC's asynchronous request processing?

Answer

Correct Answer: Inject a TaskExecutor and pass it to the Session

Note: This Question is unanswered, help us to find answer for this one

114. How do you declare a destroy method in a Spring bean?

Answer

Correct Answer: Using the destroy method

Note: This Question is unanswered, help us to find answer for this one

115. Which one of the following statements is NOT true about Spring testing annotation?

Answer

Correct Answer: @IfProfileValue:specifies testing environment of the testing method. Only one environment can be specified

Note: This Question is unanswered, help us to find answer for this one

116. Which of the following is NOT true about Spring Web Services?

Answer

Correct Answer: Spring-WS require Spring 2.x or higher

Note: This Question is unanswered, help us to find answer for this one

117. Which of the following Design Patterns is the common solution for the duplicated form submission problem in Spring MVC?

Answer

Correct Answer: Post/Redirect/Get

Note: This Question is unanswered, help us to find answer for this one

118. Which is NOT a valid way of injecting a Collection in Spring?

Answer

Correct Answer: <collection>

Note: This Question is unanswered, help us to find answer for this one

119. Which of the following correctly describes TestContextManager of Spring TestContext Framework?

Answer

Correct Answer: TestContextManager is the main entry point into the Spring TestContext Framework, which is responsible for managing a single TestContext and signaling events to all registered TestExecutionListeners

Note: This Question is unanswered, help us to find answer for this one

120. Which one of the following statements is NOT true about the following configuration in security.xml <http ...> … <form-login login-page="/login/form" login-processing-url="/login" username-parameter="username" password-parameter="password" authentication-failure-url="/login/form?error"/> </http>

Answer

Correct Answer: The authentication-failure-url attribute specifies the page that Spring Security will redirect if Spring cannot find the login page.

Note: This Question is unanswered, help us to find answer for this one

121. Which of the following object hold the information of principal currently using the application?

Answer

Correct Answer: SecurityContextHolder

Note: This Question is unanswered, help us to find answer for this one

122. Which of these is NOT a valid implementation of ApplicationContext?

Answer

Correct Answer: BeanFactoryApplicationContext

Note: This Question is unanswered, help us to find answer for this one

123. Which of the following is a disadvantage of using interfaces for proxies?

Answer

Correct Answer: proxy won't be called if one method calls another inside the proxy

Note: This Question is unanswered, help us to find answer for this one

124. Which of the following statements is NOT true about the @Autowired annotation?

Answer

Correct Answer: @Autowired annotation can be applied on more than one constructor method in the same class

Note: This Question is unanswered, help us to find answer for this one

125. Which is NOT a valid form of Advice in AOP?

Answer

Correct Answer: Before throwing advice

Note: This Question is unanswered, help us to find answer for this one

126. Which of the following is NOT a valid advice?

Answer

Correct Answer: Before throwing advice

Note: This Question is unanswered, help us to find answer for this one

127. What is the primary use of Inversion of control?

Answer

Correct Answer: For loose coupling

Note: This Question is unanswered, help us to find answer for this one

128. Which one of the following statements is true:

Answer

Correct Answer: @RequestParam annotation helps assigning the request parameter value to the method parameter.

Note: This Question is unanswered, help us to find answer for this one

129. Which of the following is the right way to pass part of URL(user) as input to the request handler method?

Answer

Correct Answer: @RequestMapping("display/{user}") public String removeMember(@PathVariable("user") String user) {}

Note: This Question is unanswered, help us to find answer for this one

130. Which Spring MVC annotation is NOT valid for use in a method?

Answer

Correct Answer: @RequestParameter

Note: This Question is unanswered, help us to find answer for this one

131. Which of the following is NOT a valid spring Application Context implementation?

Answer

Correct Answer: ConfigurableApplicationContext

Note: This Question is unanswered, help us to find answer for this one

132. What is the @PersistenceContext annotation used for?

Answer

Correct Answer: injecting a JPA entity manager

Note: This Question is unanswered, help us to find answer for this one

133. Which one of the following statements is NOT true about transactions?

Answer

Correct Answer: When managing transactions declaratively, you have to include transaction management code in each transactional operation

Note: This Question is unanswered, help us to find answer for this one

134. Which one of the following is not TRUE about Spring MVC and Ajax

Answer

Correct Answer: In order for view to be updated properly.The format of the data has to be in JSON

Note: This Question is unanswered, help us to find answer for this one

135. If a Spring bean implements BeanNameAware, which method is called with the bean id?

Answer

Correct Answer: setBeanName()

Note: This Question is unanswered, help us to find answer for this one

136. What will happen if you annotate a setter method with @Required without wiring a bean?

Answer

Correct Answer: An exception is launched

Note: This Question is unanswered, help us to find answer for this one

137. True or false? Spring's DAO classes translate SQL exceptions into general Spring exceptions

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

138. Which one of the following is NOT true about Global Transactions?

Answer

Correct Answer: In Java JTA is the only way to implement global transaction.

Note: This Question is unanswered, help us to find answer for this one

139. Which of the of the following is not a wiring mode supported by Spring?

Answer

Correct Answer: by property

Note: This Question is unanswered, help us to find answer for this one

140. Which one of the following statements is NOT true about Validation API?

Answer

Correct Answer: In Spring MVC web application context configuration <tx:annotation-driven/> will configure Spring to automatically enable the JSR-303 Bean Validation in Spring.

Note: This Question is unanswered, help us to find answer for this one

141. Which one of the following statements is NOT true?

Answer

Correct Answer: @Value annotation can be used on a class

Note: This Question is unanswered, help us to find answer for this one

142. Which of the following is NOT a way that weaving can be used?

Answer

Correct Answer: web service

Note: This Question is unanswered, help us to find answer for this one

143. Which of the following is NOT an Autowire type?

Answer

Correct Answer: byselector

Note: This Question is unanswered, help us to find answer for this one

144. DispatcherServlet class follows which design pattern?

Answer

Correct Answer: FrontController

Note: This Question is unanswered, help us to find answer for this one

145. Which of the following is NOT a valid spring bean scope?

Answer

Correct Answer: localSession

Note: This Question is unanswered, help us to find answer for this one

146. What does 'wiring' the beans do?

Answer

Correct Answer: Creates a referral to other beans.

Note: This Question is unanswered, help us to find answer for this one

147. Which of the following is an INVALID @RequestMapping declaration?

Answer

Correct Answer: @RequestMapping(request = RequestMethod.GET)

Note: This Question is unanswered, help us to find answer for this one

148. What is JdbcTemplate used for?

Answer

Correct Answer: executing SQL statements against the database

Note: This Question is unanswered, help us to find answer for this one

149. Which of the following statements BEST describes Spring Bean Factory?

Answer

Correct Answer: Spring Bean Factory creates association between collaborating objects as they are instantiated and publish events to beans that are registered as listeners

Note: This Question is unanswered, help us to find answer for this one

150. How do you refer to a collection in a Spring bean definition?

Answer

Correct Answer: <list> <ref bean="one" /> </list>

Note: This Question is unanswered, help us to find answer for this one

151. In "<property name="initialShapeSeed" value="#{ numberGuess.randomNumber }"/>", what is the name of the notation used to define the value of the property?

Answer

Correct Answer: SpEL

Note: This Question is unanswered, help us to find answer for this one

152. Which of these is NOT a Spring annotation?

Answer

Correct Answer: @View

Note: This Question is unanswered, help us to find answer for this one

153. Which if the most common scope for DAO beans?

Answer

Correct Answer: singleton

Note: This Question is unanswered, help us to find answer for this one

154. Which of the following is NOT a method of using transactions in Spring?

Answer

Correct Answer: proxies

Note: This Question is unanswered, help us to find answer for this one

155. True or False - @Inject is part of Spring Framework

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

156. True or False? Spring Integration is a part of the Spring framework you must use if you want to use beans.

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

157. Imagine I have multiple classes that have similar properties; what's a good way of handling this situation without copy/pasting the bean definitions?

Answer

Correct Answer: use bean inheritance

Note: This Question is unanswered, help us to find answer for this one

158. Which of these is NOT a Spring Bean Scope?

Answer

Correct Answer: response

Note: This Question is unanswered, help us to find answer for this one

159. To enable MVC Java config, @EnableWebMvc should be used with which of following annotation?

Answer

Correct Answer: @Configuration

Note: This Question is unanswered, help us to find answer for this one

160. How can you instantiate BeanFactory?

Answer

Correct Answer: Using FileSystemXmlApplicationContext or ClassPathXmlApplicationContext.

Note: This Question is unanswered, help us to find answer for this one

161. By default when singleton bean is instantiated?

Answer

Correct Answer: app context is created

Note: This Question is unanswered, help us to find answer for this one

162. Which of the following annotations can be used to declare a bean in Spring?

Answer

Correct Answer: @Componet, @Controller, @Service, and @Repository

Note: This Question is unanswered, help us to find answer for this one

163. Spring's JdbcTemplate is central class to interact with a database through JDBC. How can it be created?

Answer

Correct Answer: JdbcTemplate template = new JdbcTemplate(myDataSource);

Note: This Question is unanswered, help us to find answer for this one

164. Which of the following correctly describes JobLauncher?

Answer

Correct Answer: It helps in launching a job and uses JobRepository to obtain a valid JobExecution

Note: This Question is unanswered, help us to find answer for this one

165. Spring's caching support does what?

Answer

Correct Answer: abstracts a variety of different caching implementations

Note: This Question is unanswered, help us to find answer for this one

166. If a Spring bean implements BeanFactoryAware, which method is called with the bean instance?

Answer

Correct Answer: setBeanFactory()

Note: This Question is unanswered, help us to find answer for this one

167. What does the ${...} placeholder usually signify?

Answer

Correct Answer: property is read from a configuration file

Note: This Question is unanswered, help us to find answer for this one

168. What is the @Valid annotation used for?

Answer

Correct Answer: Validating @Controller inputs

Note: This Question is unanswered, help us to find answer for this one

169. True or False? Spring supports joda-time.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

170. Exceptions thrown by the Spring DAO classes are subclasses of which?

Answer

Correct Answer: DataAccessException

Note: This Question is unanswered, help us to find answer for this one

171. What are the different types of bean injection?

Answer

Correct Answer: By setter, By constructor

Note: This Question is unanswered, help us to find answer for this one

172. In Spring MVC, what is responsible for handling HTTP requests and responses?

Answer

Correct Answer: DispatcherServlet

Note: This Question is unanswered, help us to find answer for this one

173. Which of the following is an advantage of using Spring's transaction management?

Answer

Correct Answer: can easily switch between JTA and regular transactions

Note: This Question is unanswered, help us to find answer for this one

174. Which is an embedded database supported by Spring?

Answer

Correct Answer: HSQL

Note: This Question is unanswered, help us to find answer for this one

175. Which of the following best describes @Order annotation?

Answer

Correct Answer: Defines ordering as an alternative to implementing the org. springframework.core.Ordered interface

Note: This Question is unanswered, help us to find answer for this one

176. Which of the following is BAD practice, in general?

Answer

Correct Answer: all beans are prototype scope

Note: This Question is unanswered, help us to find answer for this one

177. What is the role of the @PostConstruct and @PreDestroy annotations?

Answer

Correct Answer: Similar to init and destroy method

Note: This Question is unanswered, help us to find answer for this one

178. How do you load values from property files?

Answer

Correct Answer: ${parameter_name}

Note: This Question is unanswered, help us to find answer for this one

179. In Spring, singleton means only one instance per _____.

Answer

Correct Answer: Context

Note: This Question is unanswered, help us to find answer for this one

180. How could you inject using a factory method ?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

181. Which one of the following annotation can be used to inject dependencies a) @Inject b) @Entity c) @Valid d) @Autowire

Answer

Correct Answer: @Inject and @Autowire

Note: This Question is unanswered, help us to find answer for this one

182. Which of the following concrete implementation, by default, handles the request 'first' when it is sent to a Spring MVC Framework?

Answer

Correct Answer: DispatcherServlet

Note: This Question is unanswered, help us to find answer for this one

183. What's the relationship between Spring and Maven?

Answer

Correct Answer: not much; they can be used independently and one does not require the other

Note: This Question is unanswered, help us to find answer for this one

184. Which is the most popular way of interfacing with Spring's JDBC support?

Answer

Correct Answer: JDBCTemplate

Note: This Question is unanswered, help us to find answer for this one

185. which one of the following is the correct sequence of how a normal view request is handled in a web application using Spring MVC: 1. Request: A request is submitted to the server. 2. Invokes: The dispatcher dispatches the request to the appropriate controller based on the HTTP request information and the web application configuration. 3. Service Call: The controller interacts with the service layer. 4. Response: The controller updates the model and, based on the execution result, returns the corresponding view to the user.

Answer

Correct Answer: 1234

Note: This Question is unanswered, help us to find answer for this one

186. What are the most used classes in Spring DAO?

Answer

Correct Answer: JdbcTemplate and SimpleJdbcTemplate.

Note: This Question is unanswered, help us to find answer for this one

187. What is the name of the central servlet which is part of Spring?

Answer

Correct Answer: DispatcherServlet

Note: This Question is unanswered, help us to find answer for this one

188. The transaction attribute supported by Spring includes:

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

189. What are the different points where weaving can be applied?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

190. What are the supported scopes in Hibernate?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

191. Which of the following is NOT a HTTP operation?

Answer

Correct Answer: MODIFY

Note: This Question is unanswered, help us to find answer for this one

192. What is the difference between Bean Factory and Application Context?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

193. Which of the following statements are true about Spring Testing Support?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

194. Transaction MUST follow which of the following properties?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

195. What is bean wiring?

Answer

Correct Answer: connecting the different beans (components) of an application

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

197. True or False? Spring supports lookup via JNDI.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

198. True or False? Spring provides an abstraction over JMS.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

199. Spring Security currently supports authentication integration with which of the following technology

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

200. Which of the following ORM are supported in Spring

Answer

Correct Answer: All

Note: This Question is unanswered, help us to find answer for this one

201. Which of these are types of IOC (dependency injection) ?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

202. What is NOT a way for beans to be defined?

Answer

Correct Answer: JSON

Note: This Question is unanswered, help us to find answer for this one

203. What is the SpringJUnit4ClassRunner class used for?

Answer

Correct Answer: Along with @RunWith, starting and stopping a Spring context properly while running JUnit tests

Note: This Question is unanswered, help us to find answer for this one

204. How are mocks used in Spring?

Answer

Correct Answer: They are an important part of using Spring in tests.

Note: This Question is unanswered, help us to find answer for this one

205. What does a bean definition contain?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

206. What is AOP?

Answer

Correct Answer: Aspect oriented programming

Note: This Question is unanswered, help us to find answer for this one

207. What types of transaction management does Spring support?

Answer

Correct Answer: Both of these

Note: This Question is unanswered, help us to find answer for this one

208. What are the different modules in Spring framework?

Answer

Correct Answer: JDBC abstraction and DAO module

Note: This Question is unanswered, help us to find answer for this one

209. True or False? Spring supports custom bean scopes.

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

211. In AOP, what are the different points where weaving can be applied?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one

212. What if I need a method to be called after bean construction?

Answer

Correct Answer: use init-method or @PostConstructor

Note: This Question is unanswered, help us to find answer for this one

213. What type of dependency injection does Spring NOT support?

Answer

Correct Answer: Interface injection

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

215. How many bean configuration files can you have?

Answer

Correct Answer: as many as you want

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: True

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: By marshalling & unmarshalling the objects

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

219. Does Spring support injection of Enum types?

Answer

Correct Answer: YES

Note: This Question is unanswered, help us to find answer for this one

220. @RequestMapping is part of which part of Spring?

Answer

Correct Answer: Web MVC

Note: This Question is unanswered, help us to find answer for this one

221. Which of the following is a synonym for dependency injection?

Answer

Correct Answer: inversion of control

Note: This Question is unanswered, help us to find answer for this one

222. What is one of the major improvements in Spring 3?

Answer

Correct Answer: more annotations are supported

Note: This Question is unanswered, help us to find answer for this one

223. Which annotation lets you grab the value of an HTTP request header?

Answer

Correct Answer: @RequestHeader

Note: This Question is unanswered, help us to find answer for this one

224. Which of the following is NOT a JDBC statement?

Answer

Correct Answer: Interim Statement

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Yes

Note: This Question is unanswered, help us to find answer for this one

226. How is slf4j commonly used in Spring applications?

Answer

Correct Answer: as the logging framework

Note: This Question is unanswered, help us to find answer for this one

227. 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?

Answer

Correct Answer: setMessage(String message)

Note: This Question is unanswered, help us to find answer for this one

228. Which of the following is NOT a scope available in Spring web applications?

Answer

Correct Answer: instance

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: False

Note: This Question is unanswered, help us to find answer for this one

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

Answer

Correct Answer: Mock objects

Note: This Question is unanswered, help us to find answer for this one

231. Which of these resource prefixes could be used?

Answer

Correct Answer: All of these

Note: This Question is unanswered, help us to find answer for this one