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

DOM stands for Document Object Model.

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

A - startDocument()

B - endDocument()

C - startElement()

D - endElement()

Answer : B

Explaination

endDocument() method is called at the end of a document.

Q 4 - Which component of JDOM Parser represents text of XML tag?

A - Document

B - Element

C - Attribute

D - Text

Answer : D

Explaination

Text represents the text of XML tag.

Answer : C

Explaination

XPath is used to traverse elements and attributes of an XML document. XPath provides various type of expressions which can be used to enquire relevant information from the XML document.

Answer : D

Explaination

DOM4J is java optimized, it uses java collection like List and Arrays. It works with DOM, SAX, XPath and XSLT. It can parse large XML document with very low memory footprint.

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.

Answer : C

Explaination

The DOM is a common interface for manipulating document structures. One of its design goals is that Java code written for one DOM-compliant parser should run on any other DOM-compliant parser without changes.

Q 9 - Is StAX parser a PULL API?

A - true

B - false

Answer : A

Explaination

StAX parser is a PULL API. It means in case of StAX parser, client application need to ask StAX parser to get information from XML whenever it needs.

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