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 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 : 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 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 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 the current node?

A - .

B - /

C - ./

D - //

Answer : A

Explaination

. selects the current node.

Q 7 - Which of the following method of DOM4J Parser gets all the attributes of an element?

A - Element.attributes()

B - Dom4j.attributes()

C - Document.attributes()

D - Node.attributes()

Answer : A

Explaination

Element.attributes() gets all the attributes of an element.

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