wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Unit4_Servlets_Exam1

Total questions: 24

Worksheet time: 12mins

Name
Class
Date
1.

The _______ specification defines an application programming interface for communication between the server and the application program

a)

Java Servlet

b)

java jdbc

c)

java applet

d)

java swing

2.

Which packages represent interfaces and classes for servlet API?

a)

javax.servlet

b)

javax.servlet.http

c)

both 1 and 2

d)

none of the above

3.

What is the lifecycle of a servlet?

a)

Servlet class is loaded

b)

Servlet instance is created

c)

init(),service() and destroy() methods will be called

d)

All the above

4.

How many times init() method is called during life time of a servlet?

a)

two times

b)

one time

c)

several times

d)

never called

5.

How many time destroy() method will be called during the life time of a Servlet?

a)

one

b)

two

c)

several time

d)

never called

6.

When will call init() method of a servlet?

(a)  

7.

When destroy method() of servlet called ?

a)

for first request

b)

when you close the browser window

c)

when you remove the application from server

d)

none of the above

8.

web.xml file is available in which directory of web application.

a)

root directory

b)

WEB-INF directory

c)

src

d)

classes

9.

where can you keep .java files in webapplication(Servlets)?

a)

root directory

b)

WEB-INF

c)

src

d)

classes

10.

All html pages will be placed in ----------- directory

a)

root directory

b)

WEB-INF

c)

src

d)

classes

11.

web.xml is also called as --------------------

a)

data directory

b)

deployment descriptor

c)

directroy descriptor

d)

none of the above

12.

what is root tag of web.xml ?

a)

web-app

b)

servlet

c)

servlet-mapping

d)

init-param

13.

under which tag of web.xml file contains actual servlet class

a)

web-app

b)

init-param

c)

servlet

d)

servlet-mapping

14.

Where to place user defined webapplications in webserver (Apache Tomcat)

a)

in bin directory

b)

in lib directory

c)

webapps directory

d)

work directory

15.

In which jar file contains the entire servlet API

a)

servlet-api.jar

b)

catalina.jar

c)

tomcat-api.jar

d)

jasper.jar

16.

What are the methods of ServletConfig Interface?

a)

getInitParameter()

b)

getServletName()

c)

getServletContext()

d)

all the above

17.

What are the parameters of the service() method

a)

ServletConfig,ServletContext

b)

doGet,doPost

c)

init-param

d)

ServletRequest,ServletResponse

18.

What is the parent tag of url-pattern tag in web.xml?

a)

servlet tag

b)

webapp tag

c)

servlet-mapping tag

d)

none of the above

19.

What are the methods of RequestDispatcher Interface?

a)

doGet(),doPost()

b)

include(),forward()

c)

backward(),doHead()

d)

doLink(),return

20.

How many types of cookies are available in servlets?

a)

2

b)

4

c)

8

d)

6

21.

doGet(),doPost() methods are available in which class ?

a)

GenericServlet

b)

HttpServlet

c)

Both 1 & 2

d)

None of the above

22.

How many Ways to we create Sessions?

a)

2

b)

6

c)

8

d)

4

23.

What are the different Exceptions thrown by service() method?

(a)  

24.

What are the different types of Cookies?

a)

writecookie, tempcookies

b)

strongcookie,weekcookies

c)

persistent,non-persistent

d)

none of the above