Web Application Development with JavaScript and MongoDB: Practice Exam, Exams of Technology

A practice exam for web application development using javascript and mongodb. It includes multiple-choice questions covering various topics such as javascript fundamentals, es6 features, html5, css, dom manipulation, node.js, express, and restful apis. Each question is accompanied by a detailed explanation of the correct answer, making it a valuable resource for students and developers preparing for certification or seeking to enhance their knowledge in web development. The exam covers essential concepts and best practices for building modern web applications.

Typology: Exams

2025/2026

Available from 12/21/2025

shilpi-jain-1
shilpi-jain-1 🇮🇳

4.2

(5)

29K documents

1 / 88

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Web Application Development with JavaScript
and MongoDB Certificate Practice Exam
**Question 1.** Which keyword should be used to declare a blockscoped variable that cannot
be reassigned?
A) var
B) let
C) const
D) static
**Answer:** C
**Explanation:** `const` creates a blockscoped variable whose binding cannot be changed
after initialization.
**Question 2.** In JavaScript, which of the following is a primitive data type?
A) Object
B) Array
C) Symbol
D) Function
**Answer:** C
**Explanation:** `Symbol` is a primitive type introduced in ES6, unlike objects, arrays, and
functions which are reference types.
**Question 3.** What will `typeof null` return?
A) "object"
B) "null"
C) "undefined"
D) "number"
**Answer:** A
**Explanation:** Due to a historic bug, `typeof null` evaluates to `"object"`.
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58

Partial preview of the text

Download Web Application Development with JavaScript and MongoDB: Practice Exam and more Exams Technology in PDF only on Docsity!

and MongoDB Certificate Practice Exam

Question 1. Which keyword should be used to declare a block‑scoped variable that cannot be reassigned? A) var B) let C) const D) static Answer: C Explanation: const creates a block‑scoped variable whose binding cannot be changed after initialization. Question 2. In JavaScript, which of the following is a primitive data type? A) Object B) Array C) Symbol D) Function Answer: C Explanation: Symbol is a primitive type introduced in ES6, unlike objects, arrays, and functions which are reference types. Question 3. What will typeof null return? A) "object" B) "null" C) "undefined" D) "number" Answer: A Explanation: Due to a historic bug, typeof null evaluates to "object".

and MongoDB Certificate Practice Exam

Question 4. Which loop will always execute its body at least once? A) for B) while C) do…while D) for…of Answer: C Explanation: A do…while loop checks its condition after executing the body, guaranteeing one execution. Question 5. What is the output of the following code? (() => { console.log(this); })(); (in a browser global scope) A) Window object B) undefined C) Global object (globalThis) D) The arrow function itself Answer: A Explanation: Arrow functions inherit the lexical this. In the global scope, this refers to the window object. Question 6. Which syntax correctly imports the default export from a module named utils.js? A) import { default } from './utils.js'; B) import utils from './utils.js'; C) require('./utils.js'); D) import * as utils from './utils.js';

and MongoDB Certificate Practice Exam

C) "Hello ${name}" (using backticks) D) "Hello ${name}" (using double quotes) Answer: C Explanation: Template literals require backticks; ${name} is interpolated inside them. Question 10. What does Promise.all([p1, p2]) return when both promises resolve? A) An array of the two resolved values, in order B) The first resolved value only C) A promise that resolves to the sum of both values D) A rejected promise if any promise rejects Answer: A Explanation: Promise.all resolves to an array containing each promise’s resolved value, preserving order. Question 11. Which statement correctly creates a promise that resolves after 2 seconds? A) new Promise(setTimeout(resolve, 2000)) B) new Promise((resolve) => setTimeout(resolve, 2000)) C) Promise.resolve(setTimeout(2000)) D) Promise.delay(2000) Answer: B Explanation: The executor function receives resolve; calling setTimeout(resolve, 2000) resolves after 2 seconds. Question 12. In async/await, how can you catch an error thrown by an awaited promise? A) Using .catch() after the await statement B) Wrapping the await in a try…catch block

and MongoDB Certificate Practice Exam

C) Adding error as a second argument to await D) You cannot catch errors with async/await Answer: B Explanation: Errors from awaited promises are caught by a surrounding try…catch. Question 13. Which HTML5 element is most appropriate for a navigation menu? A) B) C) D) Answer: B Explanation: semantically represents a set of navigation links. **Question 14.** Which attribute makes an element mandatory before form submission? A) required B) validate C) compulsory D) must Answer: A Explanation: The required attribute enforces that a field must be filled. Question 15. Which ARIA role should be used on a custom button element implemented with a ``? A) role="button" B) role="clickable"

and MongoDB Certificate Practice Exam

B) align-items C) flex-direction D) order Answer: B Explanation: align-items controls cross‑axis alignment; justify-content works on the main axis. Question 19. Which CSS rule creates a two‑column layout using Grid? A) grid-template-columns: repeat(2, 1fr); B) grid-template-rows: repeat(2, 1fr); C) display: flex; D) float: left; Answer: A Explanation: grid-template-columns defines column tracks; repeat(2, 1fr) creates two equal columns. Question 20. Which media query targets devices with a viewport width of 768 px or less? A) @media (max-width: 768px) {} B) @media (min-width: 768px) {} C) @media (width: 768px) {} D) @media (device-width: 768px) {} Answer: A Explanation: max-width applies the styles when the viewport is at most the specified width. Question 21. Which DOM method creates a new element node?

and MongoDB Certificate Practice Exam

A) document.createElement() B) document.getElementById() C) document.appendChild() D) document.querySelector() Answer: A Explanation: createElement constructs a fresh element that can later be inserted. Question 22. What does event.stopPropagation() do? A) Prevents the default browser action B) Stops the event from bubbling or capturing further C) Removes the event listener D) Cancels the event object entirely Answer: B Explanation: stopPropagation halts further propagation through the event flow. Question 23. Which Node.js core module provides utilities for working with file paths? A) fs B) http C) path D) os Answer: C Explanation: The path module offers methods like join, resolve, and basename. Question 24. In CommonJS, how do you export multiple functions from a file? A) module.exports = { fn1, fn2 };

and MongoDB Certificate Practice Exam

Question 27. Which HTTP status code indicates that a resource was successfully created? A) 200 B) 201 C) 204 D) 301 Answer: B Explanation: 201 Created signals that a new resource has been created, often in response to POST. Question 28. In a RESTful API, which HTTP verb is conventionally used to update a whole resource? A) PATCH B) PUT C) POST D) DELETE Answer: B Explanation: PUT replaces the entire target resource, while PATCH applies partial modifications. Question 29. Which Express route handler extracts a URL parameter named id? A) req.body.id B) req.params.id C) req.query.id D) req.headers.id Answer: B Explanation: Route parameters are accessed via req.params.

and MongoDB Certificate Practice Exam

Question 30. What does the express.json() middleware do? A) Parses URL‑encoded bodies B) Parses incoming JSON payloads into req.body C) Serves static files D) Enables CORS Answer: B Explanation: express.json() parses JSON request bodies and populates req.body. Question 31. Which statement best describes the difference between SQL and NoSQL databases? A) SQL stores data in tables; NoSQL stores data in key‑value, document, column‑family, or graph formats. B) SQL is always faster than NoSQL. C) NoSQL requires a fixed schema, SQL does not. D) SQL databases cannot be scaled horizontally. Answer: A Explanation: SQL (relational) uses tables; NoSQL offers various non‑relational models. Question 32. In MongoDB, what does BSON stand for? A) Binary Standard Notation B) Binary Serialized Object Notation C) Binary JSON D) Basic Serialized Notation Answer: C Explanation: BSON is “Binary JSON,” a binary representation used internally by MongoDB.

and MongoDB Certificate Practice Exam

Explanation: $gt stands for “greater than”. Question 36. What does the insertMany() method return in the MongoDB Node.js driver? A) The inserted documents themselves B) An object containing insertedCount and insertedIds C) A cursor for the inserted documents D) Nothing, it only throws on error Answer: B Explanation: insertMany resolves to a result object with details such as insertedCount. Question 37. Which update operator adds a new element to an array only if it does not already exist? A) $push B) $addToSet C) $pop D) $inc Answer: B Explanation: $addToSet ensures uniqueness when appending to an array. Question 38. How would you delete all documents where status equals "inactive"? A) db.collection.deleteOne({ status: "inactive" }) B) db.collection.deleteMany({ status: "inactive" }) C) db.collection.remove({ status: "inactive" }) D) db.collection.drop({ status: "inactive" }) Answer: B

and MongoDB Certificate Practice Exam

Explanation: deleteMany removes all matching documents. Question 39. Which index type is automatically created on the _id field of every MongoDB collection? A) Single‑field index B) Compound index C) Text index D) Geospatial index Answer: A Explanation: The default _id index is a single‑field (ascending) index. Question 40. What does the explain("executionStats") method provide for a query? A) The raw documents returned B) The query plan and execution statistics C) Only the index used D) The server version Answer: B Explanation: executionStats includes detailed info about how MongoDB executed the query. Question 41. In an aggregation pipeline, which stage reshapes each document by adding, removing, or renaming fields? A) $match B) $project C) $group D) $sort

and MongoDB Certificate Practice Exam

Answer: D Explanation: Setting the SameSite attribute on cookies helps mitigate CSRF attacks. Question 45. In JWT authentication, which part of the token is Base64‑encoded and contains the claims? A) Header B) Payload C) Signature D) Secret Answer: B Explanation: The payload holds the claims and is Base64‑URL encoded. Question 46. Which npm package is most commonly used to hash passwords before storing them in MongoDB? A) bcrypt B) crypto-js C) sha D) password‑hash Answer: A Explanation: bcrypt provides a strong, adaptive hashing algorithm suitable for passwords. Question 47. Which Express middleware enables Cross‑Origin Resource Sharing? A) bodyParser() B) cors() C) helmet() D) morgan()

and MongoDB Certificate Practice Exam

Answer: B Explanation: The cors package adds appropriate CORS headers. Question 48. What is the purpose of the helmet middleware in an Express app? A) Logging requests B) Parsing JSON bodies C) Securing HTTP headers D) Enabling sessions Answer: C Explanation: helmet sets various HTTP headers to improve security. Question 49. Which of the following is a valid way to start an Express server on port 3000? A) app.listen(3000, () => console.log('Running')) B) app.start(3000) C) express.run(3000) D) server.listen(3000) (without defining server) Answer: A Explanation: app.listen starts the server and optionally executes a callback. Question 50. In a Node.js REPL, which command clears the console screen? A) .clear B) .cls C) clear() D) reset() Answer: A

and MongoDB Certificate Practice Exam

Explanation: slice() without arguments returns a shallow copy of the array. Question 54. In ES6 modules, which statement correctly re‑exports a named export foo from another module? A) export { foo } from './module.js'; B) export * as foo from './module.js'; C) import { foo } from './module.js'; export foo; D) module.exports = { foo }; Answer: A Explanation: The syntax export { foo } from './module.js'; re‑exports foo. Question 55. Which of the following is NOT a valid way to handle multiple asynchronous operations concurrently? A) Promise.all([...]) B) await Promise.all([...]) C) async.eachSeries() (from async library) D) setTimeout with a loop without awaiting promises Answer: D Explanation: Using setTimeout alone does not coordinate asynchronous promises; the other options manage concurrency. Question 56. What does the Array.prototype.reduce() method return when called on an empty array without an initial value? A) undefined B) null C) Throws a TypeError

and MongoDB Certificate Practice Exam

D) 0

Answer: C Explanation: Without an initial accumulator, reduce throws a TypeError on an empty array. Question 57. Which of the following CSS properties can trigger a new stacking context? A) z-index on a positioned element B) float C) display: inline D) margin Answer: A Explanation: A positioned element with a z-index creates its own stacking context. Question 58. In the DOM, what does node.cloneNode(true) do? A) Clones the node without its children B) Clones the node and all its descendants (deep clone) C) Moves the node to a new location D) Deletes the original node Answer: B Explanation: Passing true performs a deep clone, copying the entire subtree. Question 59. Which Express method is used to serve static assets from a directory named public? A) app.use(express.static('public')) B) app.static('public') C) app.get('/static', ...)