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 by loading the complete contents of the document and creating its complete hiearchical tree in memory?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : A

Explaination

Dom Parser parses the document by loading the complete contents of the document and creating its complete hiearchical tree in memory.

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

Answer : C

Explaination

StAX is a JAVA based API to parse XML document in a similar way as SAX parser does but StAX is a PULL API where as SAX is a PUSH API.

Answer : C

Explaination

XPath is an official recommendation of the World Wide Web Consortium (W3C).It defines a language to find information in an XML file.

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 - 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 is Technology agnostic.

A - true

B - false

Answer : A

Explaination

Being plain text, XML is technology independent. It can be used by any technology for data storage and transmission purpose.

Q 9 - Is StAX parser a PULL API?

A - true

B - false

Answer : A

Explaination

StAX parser is a PULL API. It means in case of StAX parser, client application need to ask StAX parser to get information from XML whenever it needs.

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