Q. How many Node object methods are available?

  • (A) 18
  • (B) 19
  • (C) 20
  • (D) 21
πŸ’¬ Discuss
βœ… Correct Answer: (A) 18
Explanation: There are totally 18 node object methods.

Q. Which of the following Node object property returns the node immediately before a node?

  • (A) previousSibling
  • (B) textContent
  • (C) index
  • (D) localName
πŸ’¬ Discuss
βœ… Correct Answer: (A) previousSibling
Explanation: The node object property previousSibling returns the node immediately before a node.

Q. What is the purpose of the method getUserData(key)?

  • (A) Returns the associated object
  • (B) Gets the user data
  • (C) Returns the user data
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) Returns the associated object
Explanation: The method getUserData(key) returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key.

Q. How to test if two nodes are equal?

  • (A) isEqualNode()
  • (B) equal()
  • (C) ==
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) isEqualNode()
Explanation: The method isEqualNode() is used to test if two nodes are equal.

Q. How to associate an object to a key on a node?

  • (A) getUserData()
  • (B) cloneNode()
  • (C) setUserData(key,data,handler)
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) setUserData(key,data,handler)
Explanation: The method setUserData(key,data,handler) is used to associate an object to a key on a node.

Q. Which method is used to compare the placement of two nodes in the DOM hierarchy (document)?

  • (A) compareDocumentPosition()
  • (B) cloneNode()
  • (C) getUserData()
  • (D) getFeature()
πŸ’¬ Discuss
βœ… Correct Answer: (A) compareDocumentPosition()
Explanation: The compareDocumentPosition() method is used to compare the placement of two nodes in the DOM hierarchy (document).

Q. When are the keyboard events fired?

  • (A) When user manually calls the button
  • (B) When user clicks a key
  • (C) When the user calls the modifier
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) When user clicks a key
Explanation: The keydown and keyup events are fired when the user presses or releases a key on the keyboard. They are generated for modifier keys, function keys, and alphanumeric keys.

Q. How does a user generate multiple keydown events?

  • (A) Repeating the same process
  • (B) Pressing multiple keys
  • (C) Pressing the key longer than usual
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) Pressing the key longer than usual
Explanation: If the user holds the key down long enough for it to begin repeating, there will be multiple keydown events before the keyup event arrives.

Q. Which property is used to specify the key type when pressed?

  • (A) keyCode
  • (B) keyType
  • (C) keyName
  • (D) keyProperty
πŸ’¬ Discuss
βœ… Correct Answer: (A) keyCode
Explanation: The event object associated with these events has a numeric keyCode property that specifies which key was pressed.

Q. What value does the keyCode property holds when a Shift key is pressed for adding punctuation character?

  • (A) Special characters
  • (B) Alphabets
  • (C) Alphanumeric
  • (D) Digits
πŸ’¬ Discuss
βœ… Correct Answer: (D) Digits
Explanation: The number keys always generate keyCode values for the digit that appears on the key, even if you are holding down Shift in order to type a punctuation character.