Servlets - Quiz
Q1 : Which method(s) will be invoked when a
servlet is requested for the first time?
A. service
B. init
C. init followed by service
D. service followed by init
Q2 : Apart from GET and POST the other HTTP
method are
A. PUT TRACE DELETE
B. PUT OPTIONS DELETE TRACE
C. RETURN OPTIONS PUT
D. RETURN PUT DELETE TRACE
Q3 : The init method takes __ arguments of type
A. 1, ServletContext
B. 2, ServletRequest, ServletResponse
C. 0
D. 1, ServletConfig
Q4 : Which method of ServletConfig is used to
access the initialization parameters specified
in [Link]?
A. getInitParameterNames()
B. getInitParameterList()
C. getInitParameters()
D. getParameters()
Q5 : We can obtain the object of ServletContext
from ?
A. ServletConfig object via getContext()
B. ServletConfig object via getServletContext()
C. It is already available in every method
D. ServletResponse object via getContext()
Q6 : The attributes set into the object of
ServletContext can be accessed ___
A. Only in the request where it was set
B. In all responses
C. Only in the session where it was set
D. In all subsequent requests
Q7 : Which of the following sets doesn’t depict a
method of ServletRequest
A. getServerPort(), getServerName()
B. getProtocol(), getCharacterEncoding()
C. getRemoteAddress(), getRemoteHost()
D. getContentType(), getContentLength()
Q8 : In an HTML form which attribute signifies
the method to be used for submitting the
form and if not specified which is the default
method?
A. method, POST
B. method, GET
C. submit, GET
D. submit, POST
Q9 : The data which a user enters in a HTML
form element can be accessed in a servlet
via which method of ServletRequest?
A. getData
B. getAttribute
C. getParameterNames
D. getParameter
Q10 : Which method of ServletResponse is used
to write HTML response for the client
A. getWriter()
B. write()
C. writeHTML()
D. printHTML()
Q11 : The GenericServlet ?
A. extends the Servlet interface
B. implements the Servlet interface
C. extends the Servlet class
D. extends the HttpServletClass
Thank You