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 parses the document in similar fashion to DOM parser but in more easier way?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : C

Explaination

JDOM Parser parses the document in similar fashion to DOM parser but in more easier way.

Answer : D

Explaination

DOM is an official recommendation of the World Wide Web Consortium (W3C). It defines an interface that enables programs to access and update the style, structure,and contents of XML documents. XML parsers that support the DOM implement that interface.

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 method of JDOM Parser gets all the direct child nodes of an element?

A - Element.getChildren()

B - Document.getChildren()

C - Node.getChildren()

D - Node.getChild()

Answer : A

Explaination

Element.getChildren() gets all the direct child nodes of an element.

Q 5 - XPath defines the parts of an XML document like element, attribute, text, namespace, processing-instruction, comment, and document nodes.

A - true

B - false

Answer : A

Explaination

XPath defines the parts of an XML document like element, attribute, text, namespace, processing-instruction, comment, and document nodes.

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 - Can we create an XML document using DOM4J parser?

A - true

B - false

Answer : A

Explaination

Yes! Using DOM4J parser, we can parse, modify and create a XML document.

Answer : A

Explaination

Parsing XML refers to going through XML document to access data or to modify data in one or other way.

Q 9 - Can we create an XML document using StAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using StAX parser, we can parse, modify and create a XML document.

Answer : C

Explaination

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

java_xml_questions_answers.htm
Advertisements