MCQ Bank
What does validateForm() function return on invalid input?
- A) undefined
- B) null
- C) false
- D) true
What does the i modifier (flag) do in a regular expression?
- A) Matches exact text only
- B) Searches multiple lines
- C) Ignores case (case-insensitive search)
- D) Searches the whole text globally
What is the purpose of compare function in sort()?
- A) To define custom sorting order
- B) To reverse array
- C) To delete elements
- D) To join arrays
What is the role of the default case in a switch statement?
- A) It executes when no matching case is found
- B) It executes first in all cases
- C) It is a mandatory case
- D) It must always be written at the end
How can we access a form using JavaScript?
- A) document.forms["formName"]
- B) window.form()
- C) document.getElementByClass()
- D) getForm()
What is the result of typeof null?
- A) object
- B) undefined
- C) string
- D) null
What is a breakpoint in debugging?
- A) A loop inside a program
- B) A variable used in JavaScript
- C) A point where code execution temporarily stops for checking values
- D) A type of error in code
Which one is a reserved word?
- A) value
- B) myVar
- C) name
- D) class
A trailing comma in an array may cause:
- A) No change at all
- B) Better performance
- C) Unexpected behavior or errors in some cases
- D) Faster execution
All selectors in jQuery start with _______________.
- A) ~()
- B) $()
- C) %()
- D) #()
When does the finally block run in JavaScript?
- A) Only when there is an error
- B) It always runs whether there is an error or not
- C) Only when there is no error
- D) It never runs
How do you create an array in JavaScript using literal syntax?
- A) var arr = <>
- B) var arr = []
- C) var arr = ()
- D) var arr = {}
In DOM tree, a descendant can be ___________.
- A) Child, grand-child, great grand-child and so on.
- B) Parent, grand parent, great grand-parent and so on.
- C) Siblings
- D) All of the given options
What is the result of the expression "2" > "12" in JavaScript?
- A) Runtime error
- B) false
- C) true
- D) NaN
innerWidth() method of JQuery returns:
- A) width of an element including border
- B) width of an element excluding border
- C) width of an element including padding
- D) width of an element excluding padding
What is the result of Number("3.14")?
- A) NaN
- B) 3
- C) "3.14"
- D) 3.14
Which approach improves code reusability in AJAX programs?
- A) Loop structure
- B) Array usage
- C) Switch statement
- D) Callback function
What is the role of the first statement in a for loop?
- A) To display output
- B) To define the loop condition
- C) To initialize the loop variable
- D) To increment the loop variable
Which property returns XML data?
- A) getXML
- B) XMLResponse
- C) responseText
- D) responseXML
AJAX is about:
- A) Receiving data from server without reloading the whole page
- B) Both Sending and receiving data from server by reloading the whole page
- C) Sending data to server without reloading the whole page
- D) Both sending and receiving data from server without reloading the whole page