0% found this document useful (0 votes)
38 views5 pages

MCQ of Unit 6-Servlets-1

Uploaded by

Sharad Batule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views5 pages

MCQ of Unit 6-Servlets-1

Uploaded by

Sharad Batule
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CHAPTER-6 : Servlets

1.How constructor can be used for a servlet?


a) Initialization
b) Constructor function
c) Initialization and Constructor function
d) Setup() method

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)

3. When destroy() method of a filter is called?


a) The destroy() method is called only once at the end of the life cycle of a filter
b) The destroy() method is called after the filter has executed doFilter method
c) The destroy() method is called only once at the begining of the life cycle of a filter
d) The destroyer() method is called after the filter has executed

4. Which of the following is true about servlets?


a) Servlets execute within the address space of web server
b) Servlets are platform-independent because they are written in java
c) Servlets can use the full functionality of the Java class libraries
d) Servlets execute within the address space of web server, platform independent and uses the
functionality of java class libraries

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

11. What is the lifecycle of a servlet?

a. Servlet class is loaded


b. Servlet instance is created
c. init,Service,destroy method is invoked
d. All mentioned 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

13. Which are the examples of Application Server?

a. Apache
b. Tomcat
c. JBoss
d. Weblogic
e. Both C & D

14. How many techniques are used in Session Tracking?

a. 4
b. 3
c. 2
d. 5

15. What is the storage capacity of single cookie?


a) 2048 MB
b) 2048 bytes
c) 4095 bytes
d) 4095 MB

16. Servlet are used to program which component in a web application?


a) client
b) server
c) tomcat
d) applet

17. What type of protocol is HTTP?


a) stateless
b) stateful
c) transfer protocol
d) information protocol

18. What type of servlets use these methods doGet(),doTrace(),doPost(),doHead,doDelete()?


a) Genereic Servlets
b) HttpServlets
c) All of the above
d) None of these

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

20. What is the lifecycle of a servlet ?


a) Servlet class is loaded
b) Servlet instance is created
c) init, Service, destroy method is invoked
d) All of these

21. What is the difference between servlet and applet?


a) servlets execute on servers while applets execute on browser
b) servlets create static pages while applets create dynamic pages
c) servlets can execute single request while applets execute multiple requests
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()

23. The life cycle of a servlet is managed by


a) http and https
b) servlet context
c) servlet itself
d) servlet container

24. Which method take a string not a URL?


a) sendRedirect
b) forward
c) Both
d) None

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

(a) All (1), (2), (3), (4) and (5)

(b) Only (1), (2) and (3)


(c) Only (3), (4) and (5)
(d) Only (1), (4) and (5)

29. __ is the first phase of the servlet life cycle.


(a) Initialization (b) Service
(c) Destruction (d) Both (a) and (b)

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

31. A servlet is an instance of __________.


a) the Object class
b) the Applet class
c) the HttpServlet class
d) the HTTPServlet class

You might also like