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 XML based on expression and is used extensively in conjuction with XSLT?

A - XPath Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : A

Explaination

XPath Parser parses the XML based on expression and is used extensively in conjuction with XSLT.

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.

Q 4 - Which method of JDOM Parser gets the root element of the XML?

A - Element.getRootElement()

B - Document.getRootElement()

C - Node.getRootElement()

D - Node.getChild(Name)

Answer : B

Explaination

Document.getRootElement() get the root element of the XML.

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

Answer : C

Explaination

JDOM gives java developers flexibility and easy maintainablity of xml parsing code. It is light weight and quick API.

Q 10 - Can we modify an XML document using StAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using StAX parser, we can parse, modify and even create a XML document.

java_xml_questions_answers.htm
Advertisements