MCQ Bank
A while loop executes:
- A) A fixed number of times
- B) Infinite number of times
- C) As long as the condition remains true
- D) Only once
Which of the following property(ies) of XMLHttpRequest object is/are used to get a response from the server?
- A) None of the given options
- B) Both responseText & responseXML
- C) responseXML
- D) responseText
What is the syntax for selecting HTML elements and performing some action on them in jQuery?
- A) $(selector)
- B) (selector).action()
- C) None of the given options
- D) $(selector).action()
The siblings() method selects:
- A) Elements at the same level
- B) Root element
- C) Parent element
- D) Child elements
Which JavaScript method is used to find the position (index) of a match in a string?
- A) replace()
- B) test()
- C) search()
- D) matchAll()
AJAX is based on internet standards, and uses
- A) Combination of both (A) & (B)
- B) (A). XMLHttpRequest object (to retrieve data from a web server)
- C) None of the above
- D) (B). JavaScript/DOM (to display/use the data)
Best practice for DOM access is:
- A) Access repeatedly
- B) Store it in a variable
- C) Avoid DOM
- D) Delete DOM
What does the == operator check in JavaScript?
- A) Both value and data type
- B) Reference equality
- C) Only the data type
- D) Only the value
What is meant by DOM traversing in jQuery?
- A) Select on element and move upwards or downwards to reach the required elements
- B) Select child, parent, ancestor, current, descendant and sibling
- C) Find the desired elements on the basis of their relationship with other elements
- D) All of the given options
What does the === operator check in JavaScript?
- A) Both value and data type
- B) Reference equality
- C) Only the data type
- D) Only the value
In JavaScript, the Window object represents:
- A) The browser’s main window or tab environment
- B) The file system
- C) A database connection
- D) The server environment
AJAX allows:
- A) Page reload always
- B) No server communication
- C) Only HTML rendering
- D) Partial page updates
When should you use objects instead of arrays in JavaScript?
- A) When you want to avoid using new Array()
- B) When you want the element names to be numbers
- C) When you want the element names to be strings (text)
- D) When you want to create a hash array
The setInterval() function is used to:
- A) Execute code repeatedly at fixed time intervals
- B) Stop all timers
- C) Execute code once after delay
- D) Execute code only on errors
Which object is the keystone of AJAX?
- A) DOM
- B) JSON
- C) XMLHttpRequest
- D) Fetch API only
What is the purpose of the throw statement in JavaScript?
- A) It creates a custom error message
- B) It ignores the error
- C) It stops a loop
- D) It declares a variable
Why should we avoid reserved words for variables?
- A) Reduce memory
- B) Improve speed
- C) Avoid syntax errors
- D) Increase loops
What is the result of Number(true)?
- A) true
- B) 1
- C) false
- D) 0
What is the result of typeof "Hello"?
- A) string
- B) number
- C) boolean
- D) object
What does else do?
- A) Executes when condition is true
- B) Loops code
- C) Executes when condition is false
- D) Ends program