Java XML Online Quiz



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 SAX parser but in more efficient way?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : D

Explaination

StAX Parser parses the document in similar fashion to SAX parser but in more efficient way.

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 component of JDOM Parser represents XML Element?

A - Document

B - Element

C - Attribute

D - Text

Answer : B

Explaination

Element represents an XML element. Element object has methods to manipulate its child elements,its text, attributes and namespaces.

Q 4 - Which component of JDOM Parser represents XML attribute?

A - Document

B - Element

C - Attribute

D - Text

Answer : C

Explaination

Element represents an attribute of an element. Attribute has method to get and set the value of attribute. It has parent and attribute type.

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

A - true

B - false

Answer : B

Explaination

No! XPath parser is used to to navigate XML Document only. It is better to use DOM parser for creating XML.

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 of the following predicate selects the first 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 : A

Explaination

/class/student[1] predicate selects the first student element that is the child of the class element.

java_xml_questions_answers.htm
Advertisements