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 II

Q 1 - Which of the following method is used to read contents in SAX parsing?

A - startDocument()

B - characters()

C - startElement()

D - endElement()

Answer : B

Explaination

characters() method is called when character data is encountered and can be used to read contents.

Answer : C

Explaination

JDOM Parser is java optimized, it uses java collection like List and Arrays. It works with DOM and SAX APIs and combines the best of the two.

Answer : C

Explaination

JDOM Parser is of low memory footprint and is nearly as fast as SAX.

Q 4 - Which component of JDOM Parser represents DOM tree?

A - Document

B - Element

C - Attribute

D - Text

Answer : A

Explaination

Document represents the entire XML document. A Document object is often referred to as a DOM tree.

Q 5 - Which component of JDOM Parser represents XML Element?

A - Document

B - Element

C - Attribute

D - Text

Answer : B

Explaination

Element represents an XML element. Element object has methods to manipulate its child elements,its text, attributes and namespaces.

Q 6 - Which component of JDOM Parser represents XML attribute?

A - Document

B - Element

C - Attribute

D - Text

Answer : C

Explaination

Element represents an attribute of an element. Attribute has method to get and set the value of attribute. It has parent and attribute type.

Q 7 - Which component of JDOM Parser represents text of XML tag?

A - Document

B - Element

C - Attribute

D - Text

Answer : D

Explaination

Text represents the text of XML tag.

Q 8 - Which component of JDOM Parser represents comments in a XML document?

A - Comment

B - Element

C - Attribute

D - Text

Answer : A

Explaination

Comment represents comments in a XML document.

Q 9 - Which method of JDOM Parser builds the JDOM document from the xml source?

A - SAXBuilder.build(xmlSource)

B - Document.getRootElement()

C - Node.getRootElement()

D - Node.getChild(Name)

Answer : A

Explaination

SAXBuilder.build(xmlSource) builds the JDOM document from the xml source.

Q 10 - Which method of JDOM Parser gets the root element of the XML?

A - Element.getRootElement()

B - Document.getRootElement()

C - Node.getRootElement()

D - Node.getChild(Name)

Answer : B

Explaination

Document.getRootElement() get the root element of the XML.

Q 11 - Which method of JDOM Parser gets all the direct child nodes of an element?

A - Element.getChildren()

B - Document.getChildren()

C - Node.getChildren()

D - Node.getChild()

Answer : A

Explaination

Element.getChildren() gets all the direct child nodes of an element.

Q 12 - Can we create an XML document using JDOM parser?

A - true

B - false

Answer : A

Explaination

Yes! Using JDOM parser, we can parse, modify or create a XML document.

Answer : C

Explaination

StAX is a JAVA based API to parse XML document in a similar way as SAX parser does but StAX is a PULL API where as SAX is a PUSH API.

Q 14 - Which of the following class of StAX parser provide iterator of events which can be used to iterate over events as they occur while parsing the XML document?

A - XMLEventReader

B - XMLEventWriter

C - Both of the above.

D - None of the above.

Answer : A

Explaination

XMLEventReader provide iterator of events which can be used to iterate over events as they occur while parsing the XML document.

Q 15 - Which of the following class of StAX parser specifies methods for creating an event?

A - XMLEventReader

B - XMLEventWriter

C - Both of the above.

D - None of the above.

Answer : B

Explaination

XMLEventWriter specifies methods for creating an event.

Answer : C

Explaination

XPath is an official recommendation of the World Wide Web Consortium (W3C).It defines a language to find information in an XML file.

Answer : C

Explaination

XPath is used to traverse elements and attributes of an XML document. XPath provides various type of expressions which can be used to enquire relevant information from the XML document.

Q 18 - XPath defines the parts of an XML document like element, attribute, text, namespace, processing-instruction, comment, and document nodes.

A - true

B - false

Answer : A

Explaination

XPath defines the parts of an XML document like element, attribute, text, namespace, processing-instruction, comment, and document nodes.

Q 19 - XPath provides powerful path expressions select nodes or list of nodes in XML documents.

A - false

B - true

Answer : B

Explaination

XPath provides powerful path expressions select nodes or list of nodes in XML documents.

Q 20 - XPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

A - true

B - false

Answer : A

Explaination

XPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

Q 21 - XPath is one of the major element in XSLT standard and is must have knowledge in order to work with XSLT documents.

A - false

B - true

Answer : B

Explaination

XPath is one of the major element in XSLT standard and is must have knowledge in order to work with XSLT documents.

Q 22 - XPath is official recommendation of World Wide Web Consortium (W3C).

A - true

B - false

Answer : A

Explaination

XPath is official recommendation of World Wide Web Consortium (W3C).

Q 23 - Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

A - false

B - true

Answer : B

Explaination

Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

Q 24 - XPath uses a path expression to select node or list of nodes from an xml document.

A - true

B - false

Answer : A

Explaination

XPath uses a path expression to select node or list of nodes from an xml document.

Q 25 - Which of the following XPath expression will select all nodes with the given name 'nodename'?

A - nodename

B - @nodename

C - ./nodename

D - //nodename

Answer : A

Explaination

nodename selects all nodes with the given name 'nodename'.

Answer Sheet

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