JAVA XML Mock Test



This section presents you various set of Mock Tests related to JAVA XML Framework. You can download these sample mock tests at your local machine and solve offline at your convenience. Every mock test is supplied with a mock test key to let you verify the final score and grade yourself.

Questions and Answers

JAVA XML Mock Test IV

Answer : C

Explaination

The DOM is a common interface for manipulating document structures. One of its design goals is that Java code written for one DOM-compliant parser should run on any other DOM-compliant parser without changes.

Answer : C

Explaination

SAX Parser is an event-based parser for xml documents.SAX Parser is PUSH API Parser so that client application is required to get information when SAX parser notifies the client application that information is available.

Q 4 - Is SAX parser a PUSH API?

A - true

B - false

Answer : A

Explaination

SAX Parser is PUSH API Parser so that client application is required to get information when SAX parser notifies the client application that information is available.

Answer : C

Explaination

JDOM is an open source, java based library to parse XML document and it is typically java developer friendly API.

Answer : C

Explaination

JDOM is an open source, java based library to parse XML document and it is typically java developer friendly API.

Answer : C

Explaination

In both of the above situations, JDOM parser is preferred.

Answer : C

Explaination

In both of the above situations, JDOM parser is preferred.

Answer : C

Explaination

JDOM gives java developers flexibility and easy maintainablity of xml parsing code. It is light weight and quick API.

Answer : C

Explaination

StAX is a JAVA based PULL API to parse XML document. It is very quick API and uses streams.

Q 12 - Is StAX parser a PULL API?

A - true

B - false

Answer : A

Explaination

StAX parser is a PULL API. It means in case of StAX parser, client application need to ask StAX parser to get information from XML whenever it needs.

Q 13 - Is StAX parser a PULL API?

A - true

B - false

Answer : A

Explaination

StAX parser is a PULL API. It means in case of StAX parser, client application need to ask StAX parser to get information from XML whenever it needs.

Q 14 - Can we create an XML document using StAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using StAX parser, we can parse, modify and create a XML document.

Q 15 - Can we modify an XML document using SAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using SAX parser, we can parse, modify a XML document.

Q 16 - Can we modify an XML document using StAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using StAX parser, we can parse, modify and even create a XML document.

Answer : C

Explaination

In both of the above situations, StAX parser is preferred.

Answer : C

Explaination

In both of the above situations, StAX parser is preferred.

Answer : C

Explaination

In both of the above situations, StAX parser is preferred.

Q 20 - Which method of the following of StAX Parser can be used to retrieve value and attributes of element?

A - StartElement asStartElement()

B - EndElement asEndElement()

C - Characters asCharacters()

D - None of the above.

Answer : A

Explaination

StartElement asStartElement() of XMLEventReader class can be used to retrieve value and attributes of element.

Q 21 - Which method of the following of StAX Parser can be used to obtain characters such a CDATA, whitespace etc?

A - StartElement asStartElement()

B - EndElement asEndElement()

C - Characters asCharacters()

D - None of the above.

Answer : C

Explaination

Characters asCharacters() of XMLEventReader class can be used to obtain characters such a CDATA, whitespace etc.

Q 22 - Which method of the following of StAX Parser can be used to add start element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : A

Explaination

writeStartElement(String localName) of XMLStreamWriter class can be used to add start element of given name.

Q 23 - Which method of the following of StAX Parser can be used to add end element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : B

Explaination

writeEndElement(String localName) of XMLStreamWriter class can be used to add end element of given name.

Q 24 - Which of the following predicate selects the first student element that is the child of the class element?

A - /class/student[1]

B - /class/student[last()]

C - /class/student[first()-1]

D - None of the above.

Answer : A

Explaination

/class/student[1] predicate selects the first student element that is the child of the class element.

Q 25 - Which of the following predicate selects the last student element that is the child of the class element?

A - /class/student[1]

B - /class/student[last()]

C - /class/student[first()-1]

D - None of the above.

Answer : B

Explaination

/class/student[last()] predicate selects the last student element that is the child of the class element.

Answer Sheet

Question Number Answer Key
1 D
2 C
3 C
4 A
5 D
6 C
7 C
8 C
9 C
10 C
11 C
12 A
13 A
14 A
15 A
16 A
17 C
18 C
19 C
20 A
21 C
22 A
23 B
24 A
25 B
java_xml_questions_answers.htm
Advertisements