Web Designing •
MCQ • Advanced JavaScript
Most Important 30 Objective Question - Advanced JavaScript
Q1. JavaScript object is a collection of:
A) Only numbers
B) Properties and methods
C) Only strings
D) Only functions
Answer: B
Explanation:
An object in JavaScript stores data as properties and actions as methods.
Q2. Which symbol is used to access object properties?
A) #
B) .
C) @
D) &
Answer: B
Explanation:
The dot . operator is commonly used to access object properties.
Example: student.name
Q3. Which object stores multiple values in a single variable?
A) String
B) Number
C) Array
D) Boolean
Answer: C
Explanation:
An array stores multiple values in a single variable using index positions.
Q4. Array index starts from:
A) 1
B) 0
C) -1
D) 10
Answer: B
Explanation:
In JavaScript, array indexing starts from 0.
Q5. Which method adds element at the end of array?
A) pop()
B) push()
C) shift()
D) remove()
Answer: B
Explanation:
push() adds one or more elements to the end of an array.
Q6. Which method removes last element of array?
A) pop()
B) push()
C) shift()
D) delete()
Answer: A
Explanation:
pop() removes the last element from an array.
Q7. Which object is used for text handling?
A) Number
B) String
C) Boolean
D) Math
Answer: B
Explanation:
The String object is used to work with text values.
Q8. Which object is used for numeric values?
A) Number
B) String
C) Array
D) Boolean
Answer: A
Explanation:
The Number object helps manage numeric values.
Q9. Boolean object stores:
A) Numbers
B) True or False
C) Text
D) Images
Answer: B
Explanation:
Boolean stores only logical values: true and false.
Q10. Which event occurs when user clicks on an element?
A) onsubmit
B) onclick
C) onload
D) onchange
Answer: B
Explanation:
onclick event occurs when the user clicks an HTML element.
Q11. Which event occurs when form is submitted?
A) onclick
B) onsubmit
C) onfocus
D) onhover
Answer: B
Explanation:
onsubmit event triggers when a form is submitted.
Q12. Event handling means:
A) Creating database
B) Responding to user actions
C) Hosting website
D) Styling page
Answer: B
Explanation:
Event handling means executing code when users perform actions like click, submit, etc.
Q13. Which event occurs when page finishes loading?
A) onclick
B) onload
C) onsubmit
D) onblur
Answer: B
Explanation:
onload event occurs when the webpage is completely loaded.
Q14. Which event occurs when input value changes?
A) onchange
B) onsubmit
C) onclick
D) onreset
Answer: A
Explanation:
onchange occurs when the value of an input field changes.
Q15. JavaScript error handling is done using:
A) if-else
B) try-catch
C) switch
D) loop
Answer: B
Explanation:
try-catch is used to handle runtime errors in JavaScript.
Q16. Which block contains risky code?
A) catch
B) finally
C) try
D) error
Answer: C
Explanation:
The try block contains code that may generate an error.
Q17. Which block handles the error?
A) try
B) catch
C) final
D) break
Answer: B
Explanation:
The catch block handles errors that occur inside the try block.
Q18. Scope in JavaScript means:
A) Color selection
B) Area where variable is accessible
C) Browser speed
D) CSS layout
Answer: B
Explanation:
Scope defines where a variable can be accessed in the program.
Q19. Global variable can be accessed:
A) Only inside function
B) Anywhere in program
C) Only in loop
D) Only in HTML
Answer: B
Explanation:
Global variables are accessible throughout the entire program.
Q20. Local variable can be accessed:
A) Everywhere
B) Only inside its function/block
C) Only outside function
D) In CSS only
Answer: B
Explanation:
Local variables work only inside the function or block where they are declared.
Q21. Form validation is used for:
A) Styling form
B) Checking user input correctness
C) Adding image
D) Creating server
Answer: B
Explanation:
Form validation ensures the entered data is correct before submission.
Q22. Example of form validation:
A) Email format checking
B) Changing font
C) Adding table
D) Background color
Answer: A
Explanation:
Checking whether email is valid is a common example of form validation.
Q23. Responsive modal form means:
A) Static form
B) Popup form adjusting to screen size
C) Printed form
D) Hidden form
Answer: B
Explanation:
Responsive modal forms are popup forms that work properly on all screen sizes.
Q24. Which keyword creates a new object?
A) create
B) object
C) new
D) make
Answer: C
Explanation:
The new keyword is used to create object instances.
Q25. Which property gives array length?
A) size
B) count
C) length
D) total
Answer: C
Explanation:
length returns the total number of elements in an array.
Q26. Which method converts text to uppercase?
A) upper()
B) toUpperCase()
C) capitalize()
D) upperCase()
Answer: B
Explanation:
toUpperCase() converts all letters of a string into uppercase.
Q27. Which method finds text length?
A) size()
B) count()
C) length
D) total()
Answer: C
Explanation:
The length property gives the number of characters in a string.
Q28. Which statement can manually create an error?
A) break
B) continue
C) throw
D) stop
Answer: C
Explanation:
throw is used to create custom errors manually.
Q29. JavaScript validation can happen:
A) Only server side
B) Only client side
C) Both client side and server side
D) Only database side
Answer: C
Explanation:
Validation can be done in browser (client-side) and on server-side.
Q30. DOM stands for:
A) Document Object Model
B) Data Object Management
C) Digital Output Method
D) Document Operating Mode
Answer: A
Explanation:
DOM stands for Document Object Model. It allows JavaScript to access and modify HTML elements.
Google AdSense Ad Placement Here 📢