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 DOM parser but in more easier way?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : C

Explaination

JDOM Parser parses the document in similar fashion to DOM parser but in more easier way.

Answer : B

Explaination

SAX stands for Simple API for XML.

Q 3 - Which of the following method get called when element starts in SAX parsing?

A - startDocument()

B - endDocument()

C - startElement()

D - endElement()

Answer : C

Explaination

startElement() method is called at the start of an element.

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.

Q 5 - Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

A - false

B - true

Answer : B

Explaination

Predicate in XPath are used to find specific node or a node containing specific value and are defined using [...] .

Q 6 - Which of the following XPath expression selects the current node?

A - .

B - /

C - ./

D - //

Answer : A

Explaination

. selects the current node.

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 - Can we modify an XML document using SAX parser?

A - true

B - false

Answer : A

Explaination

Yes! Using SAX parser, we can parse, modify a XML document.

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