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

Answer : C

Explaination

SAX (the Simple API for XML) is an event-based parser for xml documents.Unlike a DOM parser, a SAX parser creates no parse tree.

Q 3 - Which component of JDOM Parser represents DOM tree?

A - Document

B - Element

C - Attribute

D - Text

Answer : A

Explaination

Document represents the entire XML document. A Document object is often referred to as a DOM tree.

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.

Q 6 - Which of the following XPath expression ensures that selection starts from the current node that match the selection?

A - .

B - /

C - ./

D - //

Answer : D

Explaination

// ensures that selection starts from the current node that match the selection.

Answer : C

Explaination

SAX Parser is an event-based parser for xml documents.SAX Parser is PUSH API Parser so that client application is required to get information when SAX parser notifies the client application that information is available.

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.

Q 10 - Which method of the following of StAX Parser can be used to obtain characters such a CDATA, whitespace etc?

A - StartElement asStartElement()

B - EndElement asEndElement()

C - Characters asCharacters()

D - None of the above.

Answer : C

Explaination

Characters asCharacters() of XMLEventReader class can be used to obtain characters such a CDATA, whitespace etc.

java_xml_questions_answers.htm
Advertisements