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 parses the document by loading the complete contents of the document and creating its complete hiearchical tree in memory?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : A

Explaination

Dom Parser parses the document by loading the complete contents of the document and creating its complete hiearchical tree in memory.

Q 2 - Which of the following method returns the root element of the document in DOM Parsing?

A - Node.getRoot()

B - Document.getDocumentElement()

C - Node.getFirstChild()

D - Node.getLastChild()

Answer : B

Explaination

Document.getDocumentElement() returns the root element of the document in DOM Parsing.

Q 3 - Which of the following method get called when element starts in SAX parsing?

A - startDocument()

B - endDocument()

C - startElement()

D - endElement()

Answer : C

Explaination

startElement() method is called at the start of an element.

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

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 : 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

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

Q 10 - Which method of the following of StAX Parser can be used to add end element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : B

Explaination

writeEndElement(String localName) of XMLStreamWriter class can be used to add end element of given name.

java_xml_questions_answers.htm
Advertisements