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.

Q 2 - Which of the following component represent actual content of an element or attribute in DOM Parsing?

A - Text

B - Element

C - Attr

D - Document

Answer : A

Explaination

Text represents the actual content of an Element or Attr.

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.

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 provides powerful path expressions select nodes or list of nodes in XML documents.

A - false

B - true

Answer : B

Explaination

XPath provides powerful path expressions select nodes or list of nodes in XML 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 allows Validation.

A - false

B - true

Answer : B

Explaination

Using XSD, DTD and XML structure can be validated easily.

Answer : C

Explaination

In both of the above situations, JDOM parser is preferred.

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
E-Books Store