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 provides options to parse XML, XPath and XSLT using Java Collections Framework and provides support for DOM, SAX and JAXP?

A - XPath Parser

B - DOM4J Parser

C - JDOM Parser

D - StAX Parser

Answer : B

Explaination

DOM4J Parser is a java library to parse XML, XPath and XSLT using Java Collections Framework , provides support for DOM, SAX and JAXP.

Answer : B

Explaination

SAX stands for Simple API for XML.

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

A - startDocument()

B - endDocument()

C - startElement()

D - endElement()

Answer : D

Explaination

endElement() method is called at the end of an element.

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 provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

A - true

B - false

Answer : A

Explaination

XPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

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

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.

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

Answer : C

Explaination

JDOM is an open source, java based library to parse XML document and it is typically java developer friendly API.

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