Java Servlets

Q 1 - What are Servlets?
A - Java Servlets are programs that run on a Web or Application server.
B - Java Servlets act as a middle layer between a request coming from a Web browser or other HTTP client and databases or applications on the HTTP server.
C - Both of the above.
D - None of the above.
Q 2 - Which of the following is true about destroy() method of servlet?
A - After the destroy() method is called, the servlet object is marked for garbage collection.
B - The servlet is terminated by calling the destroy() method.
C - Both of the above.
D - None of the above.
Q 3 - Which of the following code is used to get PrintWriter object in servlet?
A - response.getWriter()
B - request.getWriter()
C - new PrintWriter()
D - None of the above.
Q 4 - Which of the following code retrieves any extra path information associated with the URL the client sent?
A - Header.getPathInfo()
B - response.getPathInfo()
C - request.getPathInfo()
D - None of the above.
Q 5 - Which of the following code indicates whether the named response header has already been set?
A - response.containsHeader(headerName)
B - request.containsHeader(headerName)
C - Header.containsHeader(headerName)
D - None of the above.
Q 6 - Which of the following code can be used to add a header with the given name and integer value?
A - request.addHeader(name,value)
B - response.addIntHeader(name,value)
C - Header.addDateHeader(name,value)
D - None of the above.
Q 7 - Which of the following code can be used to set the locale of the response?
A - request.setLocale(locale)
B - response.setLocale(locale)
C - header.setLocale(locale)
D - None of the above.
Q 8 - Which element of web.xml is used to specify the error handler in servlets?
A - error-page
B - error-handler
C - exception
D - exception-handler
Q 9 - 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.
Q 10 - Which of the following code is used to set auto refresh of a page after 5 seconds?
A - session.setIntHeader("Refresh", 5)
B - response.setIntHeader("Refresh", 5)
C - request.setIntHeader("Refresh", 5)
D - None of the above.
{"name":"Java Servlets", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"Q 1 - What are Servlets?, Q 2 - Which of the following is true about destroy() method of servlet?, Q 3 - Which of the following code is used to get PrintWriter object in servlet?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Powered by: Quiz Maker