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

Explaination

When you parse an XML document with a DOM parser, you get back a tree structure that contains all of the elements of your document. The DOM provides a variety of functions you can use to examine the contents and structure of the document.

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 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 - XPath provides powerful path expressions select nodes or list of nodes in XML documents.

A - false

B - true

Answer : B

Explaination

XPath provides powerful path expressions select nodes or list of nodes in XML documents.

Q 6 - Which of the following XPath expression selects attributes?

A - .

B - ..

C - @

D - //

Answer : C

Explaination

@ selects attributes.

Q 7 - Which of the following method of DOM4J Parser gets all the attributes of an element?

A - Document.valueOf(@Name)

B - Element.valueOf(@Name)

C - Node.valueOf(@Name)

D - Dom4j.valueOf(@Name)

Answer : C

Explaination

Node.valueOf(@Name) gets all the attributes of an element.

Q 8 - XML allows Validation.

A - false

B - true

Answer : B

Explaination

Using XSD, DTD and XML structure can be validated easily.

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 add start element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : A

Explaination

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


java_xml_questions_answers.htm

Advertisements