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 builds the JDOM document from the xml source?

A - SAXBuilder.build(xmlSource)

B - Document.getRootElement()

C - Node.getRootElement()

D - Node.getChild(Name)

Answer : A

Explaination

SAXBuilder.build(xmlSource) builds the JDOM document from the xml source.

Q 5 - XPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

A - true

B - false

Answer : A

Explaination

XPath provides a rich library of standard functions for manipulation of string values, numeric values, date and time comparison, node and QName manipulation, sequence manipulation, Boolean values etc.

Q 6 - Which of the following XPath expression selects all student elements that are children of class?

A - ./class/student

B - ../class/student

C - @class/student

D - class/student

Answer : D

Explaination

class/student selects all student elements that are children of class.

Q 8 - Is SAX parser a PUSH API?

A - true

B - false

Answer : A

Explaination

SAX Parser is PUSH API Parser so that client application is required to get information when SAX parser notifies the client application that information is available.

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