This set of Java Spring Multiple Choice Questions & Answers (MCQs) focuses on “Accessing and Integrating Spring with known Frameworks”.
1. Servlet listener which loads application context.
a) Security:intercept-methods
b) global-method-security
c) ContextLoaderListener
d) None of the mentioned
View Answer
Explanation: A web application can load Spring application context by registering the servlet listener ContextLoaderListener.
2. Method to retrieve Spring Applicationcontext.
a) WebApplicationContextUtils.getRequiredWebApplicationContext()
b) WebApplicationContextUtils.getRequiredWeb()
c) WebApplicationUtils.getRequiredWebApplicationContext()
d) None of the mentioned
View Answer
Explanation: As Spring applicationcontext is stored in the servlet context, you can retrieve it through the WebApplicationContextUtils.getRequiredWebApplicationContext() method by passing in a servlet context.
3. Class used to have full access to the Spring context’s life cycle machinery and dependency injection.
a) DelegatingFilterProxy
b) WebApplicationContextUtils.getRequiredWeb()
c) WebApplicationUtils.getRequiredWebApplicationContext()
d) None of the mentioned
View Answer
Explanation: If you want to implement filter-like functionality but want to have full access to the Spring context’s life cycle machinery and dependency injection, use the DelegatingFilterProxy class.
4. In order to leverage Spring application context machinery and configuration.
a) HttpRequestHandlerJNDI
b) HttpRequestHandlerServlet
c) HttpRequestHandler
d) None of the mentioned
View Answer
Explanation: Suppose we wanted to rewrite the servlet functionality to leverage Spring application context machinery and configuration. The HttpRequestHandlerServlet will handle this for us.
5. Interface implemented by object instantiated by HttpRequestHandlerServlet.
a) HttpRequestHandlerJNDI
b) HttpRequestHandlerServlet
c) HttpRequestHandler
d) None of the mentioned
View Answer
Explanation: In the servlet example, the HttpRequestHandlerServlet delegated to another object that implemented an interface—HttpRequestHandler—that was considerably simpler than that of a raw servlet.
6. Attribute used to look up and delegate a particular root bean.
a) filter
b) filter-name
c) filtername
d) none of the mentioned
View Answer
Explanation: the filter-name attribute is used to determine which bean in the root Spring application context to look up and delegate to.
7. ActionSupport class provides a method to access spring application context.
a) getWebApplicationContext()
b) getWebApplication()
c) getApplicationContext()
d) contextEventListener()
View Answer
Explanation: Spring provides the ActionSupport class, a subclass of the Action base class that has a convenient getWebApplicationContext() method for you to access Spring application context.
8. Struts servlet used to handle web requests.
a) ActionServlet
b) Action
c) ActionSupport
d) ActionStruts
View Answer
Explanation: In the web deployment descriptor (i.e., web.xml) of a Struts application, you have to register the Struts servlet ActionServlet to handle web requests.
9. Struts plugin used to integrate with spring.
a) ContextLoaderListener
b) ContextLoaderPlugin
c) ContextLoaderListenerPlugin
d) None of the mentioned
View Answer
Explanation: Another way is to register the Struts plug-in ContextLoaderPlugin in the Struts configuration file.
10. Integration of JSF with Spring Application Context.
a) ContextLoaderListener
b) DelegatingVariableResolver
c) SpringBeanFacesELResolver
d) All of the mentioned
View Answer
Explanation: Due to the similarity between Spring and JSF bean models, it’s very easy to integrate them by registering the Spring-provided JSF variable resolver DelegatingVariableResolver (for JSF 1.1) or the SpringBeanFacesELResolver (for JSF 1.2 and greater).
11. To handle web requests in JSF.
a) FacesServlet
b) JavaFacesServlet
c) Faces-Servlet
d) None of the mentioned
View Answer
Explanation: In the web deployment descriptor (i.e., web.xml) of a JSF application, you have to register the JSF servlet FacesServlet to handle web requests.
12. Component of JSF, for user’s input in a form.
a) h:form
b) h:commandButton
c) h:outputText
d) h:inputText
View Answer
Explanation: h:form component for users to fill form.
13. Tag used to provide result of web requests and is read only.
a) h:form
b) h:commandButton
c) h:outputText
d) h:inputText
View Answer
Explanation: The distance result is defined using an h:outputText component because its value is read-only.
14. Tag which triggers server side requests.
a) h:form
b) h:commandButton
c) h:outputText
d) h:inputText
View Answer
Explanation: You define an h:commandButton component whose action will be triggered on the server side when you click it.
15. Tag used to integrate Spring with DWR.
a) dwr:integrate
b) dwr:remote
c) dwr:action
d) none of the mentioned
View Answer
Explanation: You can simply configure which beans to expose for remote invocation by embedding the
Sanfoundry Global Education & Learning Series – Java Spring.
To practice all areas of Java Spring, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice Programming MCQs
- Check Spring Books
- Apply for Programming Internship
- Check Information Technology Books