wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

JSP & Servlet Multiple Choice Questions (1-10)

Total questions: 76

Worksheet time: 38mins

Name
Class
Date
1.

JSP _____ is a process which allows the bean container to examine any class at run-time to determine its method signatures.

a)

Reflection

b)

Cookies

c)

Sockets

d)

Serialization

2.

JSP ______ is the process of creating a copy of an object suitable for passing to another object.

a)

Reflection

b)

Cookies

c)

Sockets

d)

Serialization

3.

The tasks – authentication-blocking of requests, data compression, logging and auditing – are performed by:

a)

Servlet filter

b)

Servlet config

c)

Servlet context

d)

Servlet container

4.

A deployment descriptor describes web component response settings.

a)

Web component settings

b)

Web component request objects

c)

All of the above

5.

A Java bean in a JSP can have which of the following attributes?

a)

Page

b)

Request

c)

Session

d)

All of the above

6.

A servlet maintains session in:

a)

Servlet container

b)

Servlet context

c)

Servlet request heap

d)

Servlet response heap

7.

All the __________ data is kept at the application server, __________ data is kept at the web server.

a)

Dynamic, static

b)

Static, dynamic

c)

HTML, Servlet

d)

Servlet, HTML

8.

Dynamic interception of requests and responses to transform the information is done by:

a)

Servlet container

b)

Servlet config

c)

Servlet context

d)

Servlet filter

9.

Following method(s) cannot be overridden in the JSP page.

a)

jspDestroy()

b)

jspInit()

c)

_jspService()

d)

getParameter()

10.

How many ServletContext objects are available for an entire web application?

a)

One each per servlet

b)

One each per request

c)

One each per response

d)

Only one

11.

Implementing the tag <%@ page isThreadSafe="false" %> implements the SingleThreadModel interface making the JSP ____________.

a)

Content safe

b)

Synchronized

c)

Thread safe

d)

None

12.

In the properties files ________ defines global Servlet settings and list of servlets in the system.

a)

Servlet.properties

b)

Page.properties

c)

Session.properties

d)

None

13.

J2EE consists of the following three tiers:

a)

Presentation tier, Business tier, Data tier

b)

Business tier, Implementation tier, Data tier

c)

Presentation tier, Implementation tier, Data tier

d)

None of the above

14.

JSP technology offers which of the following advantages? (1) Separation of dynamic and static content (2) Support for scripting and tags (3) Component reuse (4) Web access to N-tier architecture

a)

1 & 2

b)

All 1,2,3,4

c)

Only 1 & 3

d)

Only 2 & 4

15.

JSP is the Java platform technology for building applications containing dynamic web contents such as:

a)

XHTML, XML, DHTML, HTML

b)

CSS, JSON, YAML, SVG

c)

SQL, NoSQL, JDBC, ODBC

d)

SOAP, REST, WSDL, UDDI

16.

RequestDispatcher object is used to:

a)

Include other resources like servlet, JSP, HTML

b)

Manage HTTP sessions across servers

c)

Configure global servlet properties

d)

Handle JDBC database connections

17.

Servlet mapping defines an association between:

a)

URL pattern and servlet

b)

Session and cookie

c)

Request and response

d)

Filter and listener

18.

The _____ method performs cleanup of objects created during requests and responses.

a)

init()

b)

resume()

c)

destroy()

d)

run()

19.

The ________ component is used to locate resources over the network such as EJB components, database drivers, security credentials.

a)

JNDI

b)

JMS

c)

JavaMail

d)

EJB

20.

The ________ represents a generic exception for the JSP packages.

a)

JspException

b)

JspError

c)

ServletException

d)

IOException

21.

The __________________ when added to the user session tells us that the session timed out.

a)

SessionTimeoutIndicator

b)

SessionExpiredFlag

c)

TimeoutAttribute

d)

SessionEndMarker

22.

The getSession(true) method will return the appropriate session object when:

a)

The session does not exist

b)

The session already exists

c)

A session attribute is missing

d)

Cookies are disabled

23.

The include() method of RequestDispatcher sends a request to another resource like servlet, JSP, or HTML.

a)

True for include()

b)

False for include()

c)

True only for forward()

d)

Only for sendRedirect()

24.

The init parameter name and value pairs defined in web.xml file are handled by:

a)

ServletConfig object

b)

ServletContext object

c)

HttpSession object

d)

FilterConfig object

25.

The JSP Model I architecture uses which of the following:

a)

JSP with Beans; JSP creates bean and displays data; View is JSP

b)

Controller is Servlet or JSP; View is HTML only

c)

JSP without Beans; Controller is only Servlet

d)

Model handled by EJB only; View is JSP

26.

The life cycle of a servlet is managed by

a)

Servlet context

b)

Servlet container

c)

Supporting protocol

d)

All of the above

27.

The major difference between Servlet and CGI is:

a)

Servlet uses threads, CGI uses processes

b)

Servlet is slower than CGI

c)

CGI is platform dependent, Servlet is not

d)

All three statements

28.

The method forward(request, response) will:

a)

Return to caller

b)

Not return; continue on target resource

c)

Do both return and continue

d)

Do none of these

29.

The TCP/IP protocol is composed of the following layers:

a)

Internet Protocol

b)

Transmission Control Protocol

c)

Secure Socket Layer

d)

Sockets

30.

The three basic bean tags used in JavaServer Pages are:

a)

jsp:useBean

b)

jsp:setProperty

c)

jsp:getProperty

d)

jsp:include

31.

The three main types of JSP constructs that can be embedded in a Java Server page are:

a)

Directives

b)

Scripting Elements

c)

Actions

d)

Methods

32.

The three most important methods of the servlets are:

a)

init(), service(), destroy()

b)

doGet(), doPost(), doPut()

c)

init(), doGet(), destroy()

d)

service(), doPost(), destroy()

33.

The two different errors that may occur during the lifecycle of JSP are:

a)

Translation time errors

b)

Compile time errors

c)

Runtime expression errors

d)

Page load errors

34.

The two primary constituents of JavaBean are:

a)

Properties

b)

Methods

c)

Directives

d)

Scripts

35.

The values of and in web.xml file:

a)

Must be same

b)

Must not be same

c)

Can be same or different

d)

None

36.

To get the servlet environment information, which object is used?

a)

ServletConfig

b)

ServletException

c)

ServletContext

d)

ServletContainer

37.

To show money format on the JSP page, we use ________ class.

a)

Arithmetic Format

b)

Currency Format

c)

Number Format

d)

String Buffer

38.

Under JSP 1.0, the implicit object used to refer to the Servlet generated by the JSP page is:

a)

Servlet generated by JSP page

b)

Previous JSP page

c)

None

d)

None

39.

URL encoding is the method of replacing spaces and extra characters into their corresponding ______ characters.

a)

Hex

b)

Binary

c)

Octal

d)

Decimal

40.

What are the mechanisms available in ServletContextListener interface?

a)

contextInit(), contextService(), contextDestroyed()

b)

contextInitialized(), contextDestroyed()

c)

contextInitialized(), contextService(), contextDestroyed()

d)

None

41.

What exception must be declared by the methods of a servlet?

a)

ServletException

b)

IOException

c)

Both A and B

d)

None

42.

What is another name for the JSP container?

a)

JSP engine

b)

JSP server

c)

JSP compiler

d)

JSP executor

43.

What is the correct syntax for specifying an error page in the JSP page directive?

a)

<%@ page errorPage = "error.jsp" %>

b)

<%@ page error-page = "error.jsp" %>

c)

d)

None

44.

What is the default session timeout in Java?

a)

30 minutes

b)

20 minutes

c)

10 minutes

d)

60 minutes

45.

What is the full form of JSP?

a)

Java Server Pages

b)

Java System Pages

c)

Java Servlet Pages

d)

Java Service Programs

46.

What is the key difference between include directive and include action?

a)

Include directive is static, include action is dynamic

b)

Include directive is dynamic, include action is static

c)

Both are dynamic

d)

Both are static

47.

What is the main advantage of JSP over servlets?

a)

Separation of presentation and processing

b)

Faster than servlets

c)

More secure than servlets

d)

Fewer lines of code than servlets

48.

What is the minimum number of threads that can exist in a Java program?

a)

0

b)

1

c)

2

d)

No limit

49.

What is the type of object referenced by the 'application' implicit object?

a)

ServletContext

b)

ServletConfig

c)

HttpSession

d)

ServletRequest

50.

What is used to include another file in JSP at request time?

a)

jsp:include

b)

<%@ include %>

c)

d)

Include()

51.

Which action tag is used to forward a request to another resource?

a)

jsp:forward

b)

jsp:request

c)

jsp:redirect

d)

jsp:send

52.

Which element in web.xml is used to define servlet mapping?

a)

b)

c)

d)

53.

Which HTTP method is idempotent?

a)

GET

b)

POST

c)

PUT

d)

Both A and C

54.

Which implicit object refers to the output stream used to send content to client?

a)

out

b)

response

c)

output

d)

stream

55.

Which interface must be implemented to create a filter?

a)

Filter

b)

ServletFilter

c)

HttpFilter

d)

FilterConfig

56.

Which is responsible for converting JSP into servlet?

a)

JSP engine

b)

JSP compiler

c)

Servlet container

d)

Web server

57.

Which method is called only once in servlet lifecycle?

a)

init()

b)

service()

c)

destroy()

d)

run()

58.

Which method of HttpSession is used to get session creation time?

a)

getCreationTime()

b)

getStartTime()

c)

getInitTime()

d)

getSessionTime()

59.

Which object is used to read data from a client request?

a)

request

b)

response

c)

session

d)

servletConfig

60.

Which tag is used to use an existing bean in JSP?

a)

jsp:useBean

b)

jsp:getBean

c)

jsp:setBean

d)

jsp:bean

61.

Which directive defines page-dependent attributes like buffer, errorPage, contentType?

a)

Page directive

b)

Include directive

c)

Taglib directive

d)

None of the above

62.

Which directive declares a tag library used in JSP?

a)

Taglib directive

b)

Include directive

c)

Page directive

d)

None of the above

63.

What is the default scripting language for JSP pages?

a)

Java

b)

JavaScript

c)

VBScript

d)

Python

64.

The implicit object request in JSP is an instance of:

a)

HttpServletRequest

b)

HttpServletResponse

c)

ServletRequest

d)

ServletResponse

65.

The implicit object response in JSP is an instance of:

a)

HttpServletResponse

b)

HttpServletRequest

c)

ServletResponse

d)

ServletRequest

66.

The implicit object session in JSP is an instance of:

a)

HttpSession

b)

Session

c)

ServletSession

d)

None of the above

67.

The implicit object application in JSP is an instance of:

a)

ServletContext

b)

ServletConfig

c)

HttpSession

d)

None of the above

68.

The implicit object out in JSP is an instance of:

a)

JspWriter

b)

PrintWriter

c)

BufferedWriter

d)

OutputStream

69.

The implicit object pageContext in JSP provides:

a)

Access to all JSP implicit objects

b)

Context for current page execution

c)

Both A and B

d)

None of the above

70.

Which implicit object provides information about initialization parameters for the entire application?

a)

application

b)

config

c)

pageContext

d)

request

71.

Which implicit object is used to read parameters from client requests?

a)

request

b)

response

c)

application

d)

config

72.

Which implicit object allows JSP to include output of another resource at request time?

a)

request

b)

response

c)

pageContext

d)

application

73.

Which JSP bean scope associates a bean with a single HTTP request?

a)

request scope

b)

session scope

c)

application scope

d)

page scope

74.

Which JSP action element performs a dynamic include at request processing time?

a)

jsp:include

b)

jsp:forward

c)

jsp:param

d)

jsp:useBean

75.

In JSP, the response implicit object is an instance of:

a)

HttpServletResponse

b)

ServletResponse

c)

HttpServletRequest

d)

None of the above

76.

Which implicit object provides a handle to ServletContext, enabling application-wide attributes?

a)

application

b)

request

c)

response

d)

out