MCQ of Unit 6-Servlets-1
MCQ of Unit 6-Servlets-1
2. Which of the following code is used to get an attribute in a HTTP Session object in servlets?
a) session.getAttribute(String name)
b) session.alterAttribute(String name)
c) session.updateAttribute(String name)
d) session.setAttribute(String name)
5. Which object of HttpSession can be used to view and manipulate information about a session?
a. session identifier
b. creation time
c. last accessed time
d. All mentioned above
6. Which methods are used to bind the objects on HttpSession instance and get the objects?
a. setAttribute
b. getAttribute
c. Both A & B
d. None of the abov
7.What type of servlets use these methods doGet(), doPost(),doHead(), doDelete(), doTrace()?
a. Genereic Servlets
b. HttpServlets
c. All of the above
d. None of the above
8.Which cookie it is valid for single session only and it is removed each time when the user
closes the browser?
a. Persistent cookie
b. Non-persistent cookie
c. All the above
d. None of the above
9. Which method is used to send the same request and response objects to another servlet in
RequestDispacher ?
a. forward()
b. sendRedirect()
c. Both A & B
d. None of the above
10. Which packages represent interfaces and classes for servlet API?
a. javax.servlet
b. javax.servlet.http
c. Both A & B
d. None of the above
12. Which method in session tracking is used in a bit of information that is sent by a web
server to a browser and which can later be read back from that browser?
a. HttpSession
b. URL rewriting
c. Cookies
d. Hidden form field
a. Apache
b. Tomcat
c. JBoss
d. Weblogic
e. Both C & D
a. 4
b. 3
c. 2
d. 5
19. Which packages represent interfaces and classes for servlet API?
a) javax.servlet
b) javax.servlet.http
c) Both a and b
d) None of these
22. The doGet() method extracts values of the parameter's types and number by using
a) response.getAttribute()
b) response.getParameter()
c) request.getParameter()
d) request.setParameter()
25. Which methods are used to bind the objects HttpSession instance and get the objects?
a) setAttribute
b) getAttribute
c) both a and b
d) None of the above
26. Which cookie it is valid for single session only and it is removed each time when the user
closes the browser?
a) Persistent cookie
b) Non-persistent cookie
c) None of these
d) All of these
27. Which method in session tracking is used in a bit of information that is sent by a web server
to a browser and which can later be read back from that browser?
a) HttpSession
b)URL rewriting
c) Cookies
d) Hidden form fields
28. Which of the following methods are main methods in life cycle of servlet?
1. initO 2. serviceO
3. destroyO 4. stop()
5. waitO
30. The service phase of the servlet life cycle represents a interactions with requests until the
servlet is __ o
(a) created (b) running
(c) initiated (d) destroyed