Java XML Online Quiz



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 on event based triggers and does not load the complete document into the memory?

A - Dom Parser

B - SAX Parser

C - JDOM Parser

D - StAX Parser

Answer : B

Explaination

SAX Parser parses the document on event based triggers and does not load the complete document into the memory.

Q 2 - Which of the following method returns the root element of the document in DOM Parsing?

A - Node.getRoot()

B - Document.getDocumentElement()

C - Node.getFirstChild()

D - Node.getLastChild()

Answer : B

Explaination

Document.getDocumentElement() returns the root element of the document in DOM Parsing.

Q 3 - Can we create an XML document using SAX parser?

A - true

B - false

Answer : B

Explaination

No! Using SAX parser, we can only parse or modify a XML 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 - 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 7 - Can we create an XML document using DOM4J parser?

A - true

B - false

Answer : A

Explaination

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

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

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

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