250+ TOP MCQs on Accessing and Integrating Spring with known Frameworks and Answers

Java Spring Multiple Choice Questions & Answers (MCQs) 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
Answer: c
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: 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
Answer: c
Clarification: 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
Answer: b
Clarification: 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()
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: b
Clarification: 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
Answer: d
Clarification: 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
Answer: a
Clarification: 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
Answer: a
Clarification: 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
Answer: c
Clarification: 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
Answer: b
Clarification: 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
Answer: b
Clarification: You can simply configure which beans to expose for remote invocation by embedding the tag without involving the DWR configuration file.

Leave a Reply

Your email address will not be published. Required fields are marked *