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 III

Q 1 - Which of the following XPath expression ensures that selection starts from the root node?

A - .

B - /

C - ./

D - //

Answer : B

Explaination

/ ensures that selection starts from the root node.

Q 2 - Which of the following XPath expression ensures that selection starts from the current node that match the selection?

A - .

B - /

C - ./

D - //

Answer : D

Explaination

// ensures that selection starts from the current node that match the selection.

Q 3 - Which of the following XPath expression selects the current node?

A - .

B - /

C - ./

D - //

Answer : A

Explaination

. selects the current node.

Q 4 - Which of the following XPath expression selects the parent of the current node?

A - .

B - ..

C - ./

D - //

Answer : B

Explaination

.. selects the parent of the current node.

Q 5 - Which of the following XPath expression selects attributes?

A - .

B - ..

C - @

D - //

Answer : C

Explaination

@ selects attributes.

Q 6 - Which of the following XPath expression selects all student elements that are children of class?

A - ./class/student

B - ../class/student

C - @class/student

D - class/student

Answer : D

Explaination

class/student selects all student elements that are children of class.

Q 7 - Which of the following XPath expression selects all student elements no matter where they are in the document?

A - ../student

B - ../class/student

C - @class/student

D - //student

Answer : D

Explaination

//student selects all student elements no matter where they are in the document.

Q 8 - Can we create an XML document using XPath parser?

A - true

B - false

Answer : B

Explaination

No! XPath parser is used to to navigate XML Document only. It is better to use DOM parser for creating XML.

Answer : C

Explaination

DOM4J is an open source, java based library to parse XML document. It is highly flexible, high-performance, and memory-efficient API.

Answer : D

Explaination

DOM4J is java optimized, it uses java collection like List and Arrays. It works with DOM, SAX, XPath and XSLT. It can parse large XML document with very low memory footprint.

Q 15 - Which of the following method of DOM4J Parser builds the DOM4J document from the xml source?

A - SAXReader.read(xmlSource)

B - Dom4j.read(xmlSource)

C - Document.read(xmlSource)

D - Node.read(xmlSource)

Answer : A

Explaination

SAXReader.read(xmlSource) builds the DOM4J document from the xml source.

Q 16 - Which of the following method of DOM4J Parser gets the root element of the XML?

A - SAXReader.getRootElement()

B - Dom4j.getRootElement()

C - Document.getRootElement()

D - Node.getRootElement()

Answer : C

Explaination

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

Q 17 - Which of the following method of DOM4J Parser gets the XML node at particular index in the element?

A - Document.node(index)

B - Dom4j.node(index)

C - Element.node(index)

D - Node.node(index)

Answer : C

Explaination

Element.node(index) gets the XML node at particular index in the element.

Q 18 - Which of the following method of DOM4J Parser gets all the attributes of an element?

A - Element.attributes()

B - Dom4j.attributes()

C - Document.attributes()

D - Node.attributes()

Answer : A

Explaination

Element.attributes() gets all the attributes of an element.

Q 19 - Which of the following method of DOM4J Parser gets all the attributes of an element?

A - Document.valueOf(@Name)

B - Element.valueOf(@Name)

C - Node.valueOf(@Name)

D - Dom4j.valueOf(@Name)

Answer : C

Explaination

Node.valueOf(@Name) gets all the attributes of an element.

Q 20 - Can we create an XML document using DOM4J parser?

A - true

B - false

Answer : A

Explaination

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

Q 21 - XML is Technology agnostic.

A - true

B - false

Answer : A

Explaination

Being plain text, XML is technology independent. It can be used by any technology for data storage and transmission purpose.

Q 22 - XML is Extensible.

A - false

B - true

Answer : B

Explaination

In XML, custom tags can be created and used very easily.

Q 23 - XML allows Validation.

A - false

B - true

Answer : B

Explaination

Using XSD, DTD and XML structure can be validated easily.

Answer : A

Explaination

Parsing XML refers to going through XML document to access data or to modify data in one or other way.

Answer : C

Explaination

XML Parser provides way how to access or modify data present in an XML document.

Answer Sheet

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