JAVA
JAVA
SPRING CORE
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
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 applicationContext.xml 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 web.xml file of the web application
C. Into the java code by using annotations
D. Into the JSP pages
B,D
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. web.xml file
C. META-INF/dispatcher.xml
D. WEB-INF/dispatcher.xml
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.
JAVA WEB
=D
A. HttpServletResponce
B. HttpRequest
C. HttpResponce
D. HttpServletRequest
18. The client can access the servlet only if the servlet is installed on a ________ that
can respond to servlet requests.
=B
A. client
B.server
C.internet
D.in your network
19. All servlets must implement the Servlet interface of package:
=B
A. java.servlet
B. javax.servlet
C. java.http.servlet
D. java.io
20. Which of the following code can be used to redirect user to different url?
=B
A. request.sendRedirect(location)
B. response.sendRedirect(location)
C. header.sendRedirect(location)
D. session.sendRedirect(location)
21. Which of the following code retrieves the context of the request?
=B
A. new ClassContextPath()
B. request.getContextPath()
C. response.getContextPath()
22. A get request gets information from a client. A post request posts data to a client.
=B
A. TRUE
B. FALSE
C. Not always
D. None of these
23. What is the difference between doing an include or a forward with a
RequestDispatcher?
=D
A. The two methods provide the same functionality, but with different levels of
persistence
B. The forward method is deprecated as of JSP 1.1 and the include method should
be used in order to substitute portions of a dynamic display at runtime
C. The include method transfers control to a dynamic resource, while the forward
method allows for dynamic substitution of another JPS pages output, returning
control to the calling resource
D. The forward method transfers control to the designated resource, while the
include method invokes the designated resource, substitutes its output dynamically
in the display, and returns control to the calling page
24. Which of the following values are invalid RequestDispatcher types:
=D
A. Request
B. Forward
C. Error
D. Jsp
25. Considering the following Servlet code, choose the statements which are true:
package com.nullhaus;
import javax.servlet.annotation.*;
import javax.servlet.http.*;
@WebServlet(name=""NullServlet"")
public class NullServlet extends HttpServlet {
}
A. This is a valid usage of @WebServlet annotation
B. This is an invalid usage of @WebServlet annotation
C. This code compiles
D. This code doesn’t compile
B,C
26. Which of the following request attributes that an error-handling servlet can access
to analyse the nature of error/exception?
A. javax.servlet.error.status_code
B. javax.servlet.error.exception_type
C. javax.servlet.error.message
D. All of the above
D
27. Which of the following is true about request scope?
A. Object created with request scope are accessible only from the page in which they
are created.
B. Object created with request scope are accessible only from the page in which they
are created.
C. Object created with request scope are accessible only from the pages which are
processing the same request.
D. Object created with request scope are accessible only from the pages which reside
in same application.
C
28. Considering the following HTML form code snippet and the servlet code, what
will be the result of servlet invocation after the form has been submitted?
33. Which of the following code can be used to set the content type for the body of
the response?
A. request.setContentType(type)
B. response.setContentType(type)
C. header.setContentType(type)
D. None of the above.
B
34. Which of the following code is used to delete an attribute from a HTTP Session
object in servlets?
A. session.removeAttribute(name)
B. session.alterAttribute(name)
C. session.updateAttribute(name)
D. None of the above.
A
35. Which of the following code is used to get session id of a HTTP Session object
in servlets?
A. session.getSessionId()
B. session.getId()
C. session.getActiveId()
D. None of the above.
B
36. Which of the following code is used to update an attribute in a HTTP Session
object in servlets?
A. session.setAttribute(name, value)
B. session.alterAttribute(name, value)
C. session.updateAttribute(name, value)
D. None of the above.
A
37. Which of the following code is used to get session in servlet?
A. request.getSession()
B. response.getSession()
C. new Session()
D. None of the above
A
38. Which of the following code is used to get an attribute in a HTTP Session object in
servlets?
A. session.getAttribute(name)
B. session.alterAttribute(name)
C. session.updateAttribute(name)
D. None of the above
A
39. Which of the following is not a implicit object?
A. request
B. response
C. cookie
D. session
C
40. The getSession() method with 'true' as its parameter [ getSession(true) ] it will
return the appropriate session object when__
A. The session is completed
B. The session object is passed to another method
C. The session does not exists
D. The session is existing
D
41. Which of the following code is used to set the session timeout in servlets?
A. session.setMaxInactiveInterval(interval)
B. response.setMaxInactiveInterval(interval)
C. request.setMaxInactiveInterval(interval)
D. session.setTimeOut(interval)
A
42. Which of the following code is used to add an attribute in a HTTP Session object
in servlets?
a. session.addAttribute(name,value)
b. session.setAttribute(name,value)
c. session.createAttribute(name,value)
d. None of the above.
B
43. What are the true sentences about Session-Id?
a. Session-IDs are usually stored in the cookies, URLs and hidden fields of Web
pages
b. A session-ID is an unique identification
c. It is transmitted between the client and the server
d. All of these
D
44. What is the purpose of session management?
a. To manage the user's login and logout activities
b. To store information on the client-side between HTTP requests
c. To store information on the server-side between HTTP requests
d. To tell the web container to keep the HTTP connection alive so it can make
subsequent requests without thedelay of making the TCP connection
C
45. Which of the following are the session tracking techniques?
a. URL rewriting, using session object, using response object, using hidden field
b. URL rewriting, using session object, using cookies, using hidden fields
c. URL rewriting, using servlet object, using response object, using cookies
d. URL rewriting, using request object, using response object, using session object
B
46. Consider the following Deployment Descriptor code snippet:
...
<filter>
<filter-name>NullFilter 1</filter-name>
<filter-class>com.nullhaus.NullFilter</filter-class>
</filter>
...
package com.nullhaus;
import javax.servlet.annotation.*;
import javax.servlet.*;
@WebFilter(urlPatterns = {""/*""}, filterName=""NullFilter 1"")
public class NullFilter implements Filter {
// necessary methods goes here
}
Knowing that above DD snippet is the only filter-related part, how many filter
instances will be created by the Servlet container?
a. 0
b. 2
c. 1
d. Deployment Descriptor is invalid and the runtime exception will be thrown
C
47. Where filters are defined?
a. Filters are defined in the deployment descriptor file web.xml.
b. Filters are defined in the jsp pages.
c .Both of the above
D. None of the above
A
48. What are the mechanisms available in ServletContextListener interface?
a. contextInit(), contextService(), contextDestroyed()
b. contextInitialized((),contextDestroyed()
c. contextInitialized(), contextService(), contextDestroyed()
d. None of the above
B
49. Which deployment descriptor element is used to specify a ServletContext-
Listener? (Select one)
A . <context-listener>
B .<listener>
C .<servlet-context-listener>
D .None of the above
B
50. Which of the following is true about filters?
a. Servlet Filters are Java classes that can be used to intercept requests from a client
before they access a resource at back end
b. Servlet Filters are Java classes that can be used to manipulate responses from server
before they are sent back to the client
c. Not support in Servlet
A
51. Dynamic interception of requests and responses to transform the information is
done by
a. servlet container
b. servlet config
c. servlet context
d. servlet filter
D