Java XML Online Quiz


Advertisements


Following quiz provides Multiple Choice Questions (MCQs) related to Java XML Framework. You will have to read all the given answers and click over the correct answer. If you are not sure about the answer then you can check the answer using Show Answer button. You can use Next Quiz button to check new set of questions in the quiz.

Questions and Answers

Q 1 - Which of the following parses the document in similar fashion to SAX parser but in more efficient way?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : D

Explaination

StAX Parser parses the document in similar fashion to SAX parser but in more efficient way.

Answer : B

Explaination

SAX stands for Simple API for XML.

Q 3 - 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 4 - 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 5 - 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 : C

Explaination

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

Q 7 - 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.

Answer : C

Explaination

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

Answer : C

Explaination

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


java_xml_questions_answers.htm

Advertisements