OA. free
Free
MathWorks Core Computer Science Core Computer Science Medium

31.

MathWorks technical mcq question, verified with a worked answer. Free to practise - no sign-up.

DOM general knowledge**

Which of the following are true about DOM (Document Object Model)? Choose one or more.

Pick ONE OR MORE options

Choose one option.
Show answer & explanation
Answer: A. DOM has a tree structure.

The DOM is fundamentally a tree structure where each node has a parent (except the root), and elements are nodes within this tree hierarchy. Options B, C, and D are all false: the DOM does not allow cycles (it's strictly hierarchical), elements and nodes are distinct (elements are a type of node), and the DOM is language-agnostic—it can be accessed and modified through multiple languages (JavaScript, Python, Java, etc.), not just JavaScript.

Step-by-step Derivation:
Let's evaluate each statement:

A) DOM has a tree structure. ✓ TRUE

  • The DOM represents an XML/HTML document as a hierarchical tree with a root element, parent-child relationships, and no cycles. This is the foundational structure of the DOM spec.

B) DOM has a graph-like structure and allows cycles between elements. ✗ FALSE

  • The DOM is strictly a tree (a special case of a directed acyclic graph with no cycles). Each node has exactly one parent (except the root). Cycles are impossible in a valid DOM tree.

C) DOM's element and node are the same things. ✗ FALSE

  • Elements are a specific type of node. The DOM includes multiple node types: Element nodes, Text nodes, Comment nodes, Document nodes, etc. Not all nodes are elements.

D) DOM is tightly connected with Javascript and cannot be modified or accessed without it. ✗ FALSE

  • The DOM is a language-agnostic standard (W3C specification). It can be accessed and manipulated via JavaScript, Python (BeautifulSoup, lxml), Java (DOM parsers), C++, and many other languages. JavaScript is just one common way to interact with the DOM in browsers.