Java XML Online Quiz



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 component represent base datatype of the DOM in DOM Parsing?

A - Node

B - Element

C - Attr

D - Document

Answer : A

Explaination

Node represents the base datatype of the DOM.

Q 2 - Which of the following method returns the first child of a given Node in DOM Parsing?

A - Node.getChild()

B - Document.getFirstChild()

C - Node.getFirstChild()

D - Node.getLastChild()

Answer : C

Explaination

Node.getFirstChild() returns the first child of a given Node in DOM Parsing.

Q 3 - 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 4 - 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 5 - 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 6 - 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 7 - 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.

Answer : A

Explaination

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

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

Answer : C

Explaination

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

java_xml_questions_answers.htm
Advertisements