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.

Answer : C

Explaination

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

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

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

Answer : C

Explaination

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

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

java_xml_questions_answers.htm
Advertisements