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

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

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 is Extensible.

A - false

B - true

Answer : B

Explaination

In XML, custom tags can be created and used very easily.

Answer : C

Explaination

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

Q 10 - Which of the following predicate selects the last student element that is the child of the class element?

A - /class/student[1]

B - /class/student[last()]

C - /class/student[first()-1]

D - None of the above.

Answer : B

Explaination

/class/student[last()] predicate selects the last student element that is the child of the class element.


java_xml_questions_answers.htm

Advertisements