MCQ Bank
What is responseXML used for?
- A) Rendering HTML only
- B) Handling CSS data
- C) Parsing XML response data
- D) Processing JSON only
What does setting async = true mean in an AJAX request?
- A) The server does not respond
- B) The browser stops execution until response is received
- C) The request is disabled
- D) The request runs in the background without blocking the page
What is the result of typeof NaN?
- A) string
- B) number
- C) undefined
- D) NaN
Which of the following method(s) is/are used for traversing up the DOM tree?
- A) parent()
- B) grandParents()
- C) parental()
- D) parents() and grandParents()
Loop performance improves when you:
- A) Move calculations outside the loop
- B) Use recursion
- C) Increase iterations
- D) Add extra variables
Why should we avoid eval()?
- A) All of the above
- B) It is unnecessary
- C) It has security risks
- D) It is slow
The break statement is commonly used in:
- A) Objects
- B) Functions
- C) Loops and switch statements
- D) Arrays
Client-side validation is performed by:
- A) Browser
- B) Firewall
- C) Database
- D) Server
To traverse sideways in the DOM Tree, ___________ is not a function.
- A) siblings()
- B) nextUntil()
- C) next()
- D) nexts()
What is the purpose of the debugger keyword in JavaScript?
- A) It makes the code run faster
- B) It compiles the code into HTML
- C) It removes all errors automatically
- D) It pauses code execution for debugging purposes
What is the primary use of the splice() method?
- A) Adds and/or removes elements from the array
- B) Only deletes elements from the array
- C) Sorts the elements of the array
- D) Only adds elements to the array
Which condition confirms that an AJAX request was successfully completed?
- A) readyState == 0 and status == 200
- B) readyState == 4 and status == 200
- C) readyState == 1 and status == 500
- D) readyState == 2 and status == 404
What happens if you use a variable before declaring it (with var)?
- A) The program stops immediately
- B) It may return undefined
- C) It gives a syntax error
- D) It always gives a runtime error
In AJAX, which event is used to check the status of a server response?
- A) onreadystatechange
- B) onsubmit
- C) onclick
- D) onload
Why should we avoid global variables?
- A) They run faster
- B) They can be changed from anywhere in the program
- C) They are always required
- D) They increase security
The JQuery code: $("p").hide() will hide _________.
- A) all <p> elements
- B) None of the given options
- C) only last <p> element
- D) only first <p> element
What does the typeof operator return for arrays in JavaScript?
- A) string
- B) array
- C) index
- D) object
The statement window.alert() is equivalent to:
- A) print()
- B) console.log()
- C) document.write()
- D) alert()
Which is a floating point issue?
- A) 2 * 2 = 4
- B) 1 + 1 = 2
- C) 5 + 5 = 10
- D) 0.1 + 0.2 is not exactly 0.3
The third statement in a for loop is responsible for:
- A) Initialization
- B) Displaying output
- C) Condition checking
- D) Incrementing or decrementing the loop variable