1. What does a Node object represent?
a) Single node
b) Set of nodes
c) Sequence of nodes
d) Node array
Explanation: The Node object represents a single node in the document tree. A node can be an element node, an attribute node, a text node, or any other of the node types explained in the Node Types chapter.
2. What does the nodeName of the nodeType Document return?
a) doctype name
Explanation: The nodeName of the nodeType Document returns #document. If the node is an element node, the nodeName property will return the tag name. If the node is an attribute node, the nodeName property will return the name of the attribute.
3. What is the purpose of the method item()?
a) Returns node after the specified index
b) Returns node before the specified index
c) Returns node at specified index
d) Returns the node following the specified node
Explanation: The method item() returns the node at the specified index in a node list. The nodes are sorted as they appear in the source code, and the index starts at 0.A Node object’s collection of child nodes is an example of a NodeList object.
4. How can the nodes in the node list be accessed?
b) Index number
Explanation: The nodes in the node list can be accessed through their index number. The nodes are sorted as they appear in the source code, and the index starts at 0.
5. Which of the following is the child(s) of the node type EntityReference?
c) Both Element and Text
Explanation: The createEntityReference() method creates the specified EntityReference Object. The children of the node type EntityReference are Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference.
6. Which node type represents the root-node of the DOM tree?
Explanation: Everything inside an html document is classified in the form of different nodes. The node type Document represents the root-node of the DOM tree, the entire document.
7. What is the purpose of the DocumentFragment node type?
a) To hold a portion of a document
b) To split the document into fragments
c) To hold the entire document
d) To hold the fragments
Explanation: The DocumentFragment node type represents a “lightweight” Document object that has no parent. It is used as a lightweight version of Document that stores a segment of a document structure comprised of nodes just like a standard document.
8. How many nodetype – named constants are available?
Explanation: DOM nodes can be of various types, such as element nodes and text nodes, and each node has a nodeType property giving its type. There are totally 12 nodetype – named constants available.
9. Which of the following Node types have a node value equal to null?
d) All of the mentioned
Explanation: All the three node types namely, Document, DocumentFragment, DocumentType have a node value equal to null. If the node is an element node, the nodeType property will return 1. If the node is an attribute node, the nodeType property will return 2.
10. How many node object properties are there?
Explanation: Node interface is the primary datatype for the entire Document Object Model. The node is used to represent a single XML element in the entire document tree. There are totally 16 node object properties.