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 XML based on expression and is used extensively in conjuction with XSLT?

A - XPath Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : A

Explaination

XPath Parser parses the XML based on expression and is used extensively in conjuction with XSLT.

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 begins in SAX parsing?

A - startDocument()

B - endDocument()

C - startElement()

D - endElement()

Answer : A

Explaination

startDocument() method is called at the beginning of a document.

Q 4 - Which of the following class of StAX parser specifies methods for creating an event?

A - XMLEventReader

B - XMLEventWriter

C - Both of the above.

D - None of the above.

Answer : B

Explaination

XMLEventWriter specifies methods for creating an event.

Q 5 - Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

A - false

B - true

Answer : B

Explaination

Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

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 builds the DOM4J document from the xml source?

A - SAXReader.read(xmlSource)

B - Dom4j.read(xmlSource)

C - Document.read(xmlSource)

D - Node.read(xmlSource)

Answer : A

Explaination

SAXReader.read(xmlSource) builds the DOM4J document from the xml source.

Answer : C

Explaination

The DOM is a common interface for manipulating document structures. One of its design goals is that Java code written for one DOM-compliant parser should run on any other DOM-compliant parser without changes.

Answer : C

Explaination

JDOM is an open source, java based library to parse XML document and it is typically java developer friendly API.

Q 10 - Which method of the following of StAX Parser can be used to add end element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : B

Explaination

writeEndElement(String localName) of XMLStreamWriter class can be used to add end element of given name.


java_xml_questions_answers.htm

Advertisements