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 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 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 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 - XPath uses a path expression to select node or list of nodes from an xml document.

A - true

B - false

Answer : A

Explaination

XPath uses a path expression to select node or list of nodes from an xml document.

Q 6 - Which of the following XPath expression selects the current node?

A - .

B - /

C - ./

D - //

Answer : A

Explaination

. selects the current node.

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.

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 method of the following of StAX Parser can be used to add start element of given name?

A - writeStartElement(String localName)

B - writeEndElement(String localName)

C - writeAttribute(String localName, String value)

D - None of the above.

Answer : A

Explaination

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

java_xml_questions_answers.htm
Advertisements