Spring Questions and Answers – Accessing and Integrating Spring with known Frameworks

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

Answer: c
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

Answer: a
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

Answer: a
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.
advertisement
advertisement

4. In order to leverage Spring application context machinery and configuration.
a) HttpRequestHandlerJNDI
b) HttpRequestHandlerServlet
c) HttpRequestHandler
d) None of the mentioned
View Answer

Answer: b
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

Answer: c
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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

Answer: b
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

Answer: a
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.
advertisement

8. Struts servlet used to handle web requests.
a) ActionServlet
b) Action
c) ActionSupport
d) ActionStruts
View Answer

Answer: a
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

Answer: b
Explanation: Another way is to register the Struts plug-in ContextLoaderPlugin in the Struts configuration file.
advertisement

10. Integration of JSF with Spring Application Context.
a) ContextLoaderListener
b) DelegatingVariableResolver
c) SpringBeanFacesELResolver
d) All of the mentioned
View Answer

Answer: d
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

Answer: a
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

Answer: a
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

Answer: c
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

Answer: b
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

Answer: b
Explanation: You can simply configure which beans to expose for remote invocation by embedding the tag without involving the DWR configuration file.

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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.