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 component represent base datatype of the DOM in DOM Parsing?

A - Node

B - Element

C - Attr

D - Document

Answer : A

Explaination

Node represents the base datatype of the DOM.

Q 2 - Which of the following method returns the first child of a given Node in DOM Parsing?

A - Node.getChild()

B - Document.getFirstChild()

C - Node.getFirstChild()

D - Node.getLastChild()

Answer : C

Explaination

Node.getFirstChild() returns the first child of a given Node in DOM Parsing.

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.

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 the XML node at particular index in the element?

A - Document.node(index)

B - Dom4j.node(index)

C - Element.node(index)

D - Node.node(index)

Answer : C

Explaination

Element.node(index) gets the XML node at particular index in the element.

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 retrieve value and attributes of element?

A - StartElement asStartElement()

B - EndElement asEndElement()

C - Characters asCharacters()

D - None of the above.

Answer : A

Explaination

StartElement asStartElement() of XMLEventReader class can be used to retrieve value and attributes of element.

java_xml_questions_answers.htm
Advertisements