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 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 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 method of JDOM Parser builds the JDOM document from the xml source?

A - SAXBuilder.build(xmlSource)

B - Document.getRootElement()

C - Node.getRootElement()

D - Node.getChild(Name)

Answer : A

Explaination

SAXBuilder.build(xmlSource) builds the JDOM document from the xml source.

Q 5 - XPath is one of the major element in XSLT standard and is must have knowledge in order to work with XSLT documents.

A - false

B - true

Answer : B

Explaination

XPath is one of the major element in XSLT standard and is must have knowledge in order to work with XSLT documents.

Q 6 - Which of the following XPath expression selects all student elements that are children of class?

A - ./class/student

B - ../class/student

C - @class/student

D - class/student

Answer : D

Explaination

class/student selects all student elements that are children of class.

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.

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

StAX is a JAVA based PULL API to parse XML document. It is very quick API and uses streams.

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