MCQ Bank
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
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