wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Servlets, JSP & XML

Total questions: 70

Worksheet time: 35mins

Name
Class
Date
1.

Which are the main features of XML?

a)

Text data description

b)

Human- and computer-friendly format

c)

Handles data in a tree structure having one-and only one-root element

d)

All mentioned above

2.

Find the correct syntax of the declaration which defines the XML Version?

a)

< ?xml version= "1.0" ? >

b)

< xml version="1.0"/ >

c)

< ?xml version="1.0" / >

d)

None of the above

3.

Which language is case sensitive?

a)

HTML

b)

XML

c)

Both A & B

d)

None of the above

4.

Which are the techniques for defining the structure of a specific type of XML documents?

a)

Schema

b)

DTD

c)

Both A & B

d)

None of the above

5.

Which is not a XML function?

a)

Transport information

b)

Style information

c)

Store information

d)

Structure information

6.

Is this a 'well formed' XML document?

< ?xml version="1.0"? >

< note >

< to age="29" >John< /to >

< from >Smiley< / from >

< / note >

a)

True

b)

False

7.

Which Characters are illegal in XML elements?

a)

" < "

b)

"&"

c)

Both A & B

d)

None of the above

8.

Which are the XML Syntax rules?

a)

All XML Elements Must Have a Closing Tag

b)

XML Tags are not Case Sensitive

c)

XML Elements Must be Properly Nested

d)

Both A & C

9.

XML is designed to store data and _____.

a)

Design

b)

Verify

c)

Transport

d)

Both A & B

10.

Well formed XML document means

a)

it contains a root element

b)

it contain an element

c)

it contains one or more elements

d)

must contain one or more elements and root element must contain all other elements

11.

Valid XML document means (most appropriate)

a)

the document has root element

b)

the document contains atleast one or more root element

c)

the XML document has DTD associated with it & it complies with that DTD

d)

Each element must nest inside any enclosing element property

12.

What does DTD stand for?

a)

Direct Type Definition

b)

Document Type Definition

c)

Do The Dance

d)

Dynamic Type Definition

13.

The use of a DTD in XML development is:

a)

required when validating XML documents

b)

no longer necessary after the XML editor has been customized

c)

used to direct conversion using an XSLT processor

d)

a good guide to populating a templates to be filled in when generating an XML document automatically

14.

In XML

a)

the internal DTD subset is read before the external DTD

b)

the external DTD subset is read before the internal DTD

c)

there is no external type of DTD

d)

there is no internal type of DTD

15.

Disadvantages of DTD are

(i)DTDs are not extensible

(ii)DTDs are not in to support for namespaces

(iii)there is no provision for inheritance from one DTDs to another

a)

(i) is correct

b)

(i),(ii) are correct

c)

(ii),(iii) are correct

d)

(i),(ii),(iii) are correct

16.

To use the external DTD we have the syntax

a)

<?xml version=”A.0” standalone=”no”?>

<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>

b)

<?xml version=”A.0” standalone=”yes”?>

<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>

c)

<?xml version=”A.0” standalone=”no”?>

<! DOCTYPE DOCUMENT “order.dtd”?>

d)

<?xml version=”A.0” standalone=”yes”?>

<! DOCTYPE DOCUMENT SYSTEM “order.dtd”?>

17.

A schema describes

(i) grammer

(ii) vocabulary

(iii) structure

(iv) datatype of XML document

a)

(i) & (ii) are correct

b)

(i),(iii) ,(iv) are correct

c)

(i),(ii),(iv) are correct

d)

(i),(ii),(iii),(iv) are correct

18.

The attribute used to define a new namespace is

A. XMLNS

a)

XmlNameSpace

b)

XMLNS

c)

xmlns

d)

XmlNs

19.

Which of the following is a valid XSLT iteration command

a)

for

b)

for-all

c)

for-each

d)

in-turn

20.

______ tag is an extension to HTML that can enclose any number of JavaScript statements.

a)

<SCRIPT>

b)

<BODY>

c)

<HEAD>

d)

<TITLE>

21.

What is the correct JavaScript syntax to write "Hello World"?

a)

System.out.println("Hello World")

b)

println ("Hello World")

c)

document.write("Hello World")

d)

response.write("Hello World")

22.

What is the correct syntax for referring to an external script called " abc.js"?

a)

<script href=" abc.js">

b)

<script name=" abc.js">

c)

<script src=" abc.js">

d)

None of the above

23.

Which of the following best describes JavaScript?

a)

a low-level programming language.

b)

a scripting language precompiled in the browser.

c)

a compiled scripting language.

d)

an object-oriented scripting language.

24.

JavaScript is interpreted by _________

a)

Client

b)

Server

c)

Object

d)

None of the above

25.

<script type="text/javascript">

x=4+"4";

document.write(x);

</script>

Output------?

a)

44

b)

8

c)

4

d)

Error output

26.

Which page directive should be used in JSP to generate a PDF page?

a)

contentType

b)

generatePdf

c)

typePDF

d)

contentPDF

27.

application is instance of which class?

a)

javax.servlet.Application

b)

javax.servlet.HttpContext

c)

javax.servlet.Context

d)

javax.servlet.ServletContext

28.

Which option is true about session scope?

a)

Objects are accessible only from the page in which they are created

b)

Objects are accessible only from the pages which are in same session

c)

Objects are accessible only from the pages which are processing the same request

d)

Objects are accessible only from the pages which reside in same application

29.

Which one is the correct order of phases in JSP life cycle?

a)

Initialization, Cleanup, Compilation, Execution

b)

Initialization, Compilation, Cleanup, Execution

c)

Compilation, Initialization, Execution, Cleanup

d)

Cleanup, Compilation, Initialization, Execution

30.

“request” is instance of which one of the following classes?

a)

Request

b)

HttpRequest

c)

HttpServletRequest

d)

ServletRequest

31.

Which is not a directive?

a)

include

b)

page

c)

export

d)

useBean

32.

Which one of the following is correct for directive in JSP?

a)

<%@directive%>

b)

<%!directive%>

c)

<%directive%>

d)

<%=directive%>

33.

Which of the following action variable is used to include a file in JSP?

a)

jsp:setProperty

b)

jsp:getProperty

c)

jsp:include

d)

jsp:plugin

34.

“out” is implicit object of which class?

a)

javax.servlet.jsp.PrintWriter

b)

javax.servlet.jsp.SessionWriter

c)

javax.servlet.jsp.SessionPrinter

d)

javax.servlet.jsp.JspWriter

35.

Java code is embedded under which tag in JSP?

a)

Declaration

b)

Scriptlet

c)

Expression

d)

Comment

36.

Which of the following are the valid scopes in JSP?

a)

request, page, session, application

b)

request, page, session, global

c)

response, page, session, application

d)

request, page, context, application

37.

How many jsp implicit objects are there and these objects are created by the web container that are available to all the jsp pages?

a)

8

b)

9

c)

10

d)

7

38.

Which attribute specifies a JSP page that should process any exceptions thrown but not caught in the current page?

a)

The ErrorPage Attribute

b)

The IsErrorPage Attribute

c)

Both A & B

d)

None of the above

39.

In JSP Action tags which tags are used for bean development?

a)

jsp:useBean

b)

jsp:setPoperty

c)

jsp:getProperty

d)

All mentioned above

40.

Which technology do we mix our business logic with the presentation logic?

a)

Servlet

b)

JSP

c)

Both A & B

d)

None of the above

41.

In JSP page directive which attribute defines the MIME(Multipurpose Internet Mail Extension) type of the HTTP response?

a)

import

b)

contentType

c)

extends

d)

info

42.

A JSP page consists of which tags?

a)

HTML tags

b)

JSP tags

c)

Both A & B

d)

None of the above

43.

Which packages does a JSP API consist of?

a)

javax.servlet.jsp

b)

java.servlet

c)

javax.servlet.jsp.tagext

d)

Both A & C

44.

Choose an incorrect statement from the following.

a)

JSP pages are easier to maintain than a servlet.

b)

The Web Container translate a Servlet into JSP page.

c)

JSP is built on Java Technology so it is platform independent.

d)

A JSP page seperates presentation and business logic.

45.

Which syntax is used to comment in JSP?

a)

<!-- Comment -->

b)

<@-- Comment -->

c)

<%-- Comment -->

d)

<&-- Comment -->

46.

Which of the following is syntax of Declaration Tag?

a)

<@ Declaration @>

b)

<% Declaration %>

c)

<& Declaration &>

d)

<%! Declaration %>

47.

Which is an example of the syntax used to import a class to JSP?

a)

<% page import="java.util.List" %>

b)

<%@ page import="java.util.List" @%>

c)

<% import="java.util.List" %>

d)

<%@ page import="java.util.List" %>

48.

Which of the following is syntax of Expression Tag?

a)

<% Expression %>

b)

<%= Expression %>

c)

<& Expression &>

d)

<%! Expression %>

49.

An __________ tag can hold any Java language expression that can be used as an argument to out.println() method.

a)

Expression tag

b)

Declaration Tag/label>

c)

Directive Tag

d)

Scriplet Tag

50.

Never end an expression with semicolon inside Expression Tag?

a)

True

b)

False

51.

Which implicit object of JSP is equivalent to this variable of Java programming language?

a)

page

b)

pageContext

c)

config

d)

application

52.

Which implicit object is only available to a JSP page which is designated as error pages?

a)

application

b)

Throwable

c)

runnable

d)

exception

53.

Choose the correct syntax of include directive?

a)

<%@ include page="file.jsp" %>

b)

<% include file="file.jsp" %>

c)

<%@ include file="file.jsp" %>

d)

<%! include page="file.jsp" %>

54.

Servlet runs each request in a __________ ?

a)

OS shell

b)

JVM

c)

Separate thread

d)

JRE

55.

GenericServlet class is encapsulated inside __________ package

a)

java.lang

b)

javax.servlet

c)

java.servlet

d)

javax.servlet.http

56.

Which class provide implementation for service() method ?

a)

GenericServlet

b)

HttpServlet

c)

Servlet

d)

none of the above

57.

_________ is responsible for managing execution of servlet

a)

Web Container

b)

Servlet Context

c)

JVM

d)

Server

58.

Deployment Descriptor(DD) is a _________ .

a)

Servlet used to maintain other servlet.

b)

Text document

c)

XML document that is used by Web Container to run servlets and JSPs.

d)

Library file.

59.

Which method is called only once in Servlet life cycle ?

a)

service()

b)

initialize()

c)

init()

d)

all of the above

60.

Which of these classes define the getWriter() method that returns an object of type PrintWriter ? Select the one correct answer. ?

a)

HttpServletRequest

b)

HttpServletResponse

c)

ServletConfig

d)

ServletContext

61.

Which method defined in the HttpServletRequest returns the object of RequestDispatcher ?

a)

getRequestDispatcher()

b)

getDispatcher()

c)

getRequest()

d)

requestDispatcher()

62.

When the Web Container initializes a servlet, it creates a ___________ object for the servlet ?

a)

ServletConfig

b)

ServletInit

c)

ServletContext

d)

None of the above

63.

____________ object is available to any servlet or JSPs that are part of the web app and provides communication between servlets and JSPs.

a)

Servlet

b)

ServletConfig

c)

ServletContext

d)

HttpServletContext

64.

If the client has disabled cookie in the browser, which session management mechanism could the web container employ ?

a)

Session Management using Cookies

b)

Session Management using URL rewriting

c)

Either Cookies or URL rewriting

d)

Cookies and URL rewriting must be used together

65.

Which statement about HttpSession is not true?

a)

HttpSession object is used to store entire session with a specific client

b)

Any servlet can have access to HttpSession object through the getSession() method

c)

A session will become invalid as soon as the user close all the browser window

d)

Attribute can be stored, retrieved and removed from HttpSession object

66.

Given request is an HttpServletRequest, which code snippets will creates a session if one doesn't exist?

a)

request.getSession(false);

b)

request.createSession();

c)

request.getNewSession();

d)

request.getSession();

67.

Which method is used access the cookies that are added to response object?

a)

getCookies()

b)

getNewCookies();

c)

cookies();

d)

returnCookies();

68.

Which statement is true for request.getSession(true) method?

a)

if session already exist, it return the existing session else create a new session

b)

getSession(true) method always returns a new session

c)

getSession(true) method always returns a pre existing session

d)

none

69.

Cookies are stored on _______ side.

a)

Client

b)

Server

c)

database

d)

none

70.

Which method is used to delete a session?

a)

invalidateSession()

b)

invalidate()

c)

deleteSession()

d)

delete()