Node.js Developer Course Practice Exam Questions, Exams of Technology

Practice exam questions for a node.js developer course, covering topics such as v8 engine, event loop, promises, async/await, commonjs, package.json, semantic versioning, core modules, express, http methods, restful design, nosql databases, mongodb, mongoose, jwt, cors, and helmet middleware. It provides explanations for each answer, making it a valuable resource for exam preparation and understanding node.js concepts. The questions are designed to test knowledge of node.js development principles and best practices, suitable for developers looking to enhance their skills and prepare for certification.

Typology: Exams

2025/2026

Available from 12/22/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
The Complete Node js Developer Course
3rd Edition Certificate Practice Exam
**Question 1.** Which component of Node.js is responsible for executing JavaScript code?
A) libuv
B) V8 Engine
C) HTTP Module
D) Event Loop
Answer: B
Explanation: The V8 Engine, developed by Google, compiles and executes JavaScript code in
Node.js.
**Question 2.** In the Node.js event loop, which phase handles timers such as `setTimeout`
and `setInterval`?
A) Poll
B) Timers
C) Check
D) Close callbacks
Answer: B
Explanation: The Timers phase processes callbacks scheduled by `setTimeout` and `setInterval`.
**Question 3.** Which queue has higher priority: microtasks or macrotasks?
A) Macrotasks
B) Microtasks
C) Both have equal priority
D) It depends on the Node version
Answer: B
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 Node.js Developer Course Practice Exam Questions and more Exams Technology in PDF only on Docsity!

3rd Edition Certificate Practice Exam

Question 1. Which component of Node.js is responsible for executing JavaScript code? A) libuv B) V8 Engine C) HTTP Module D) Event Loop Answer: B Explanation: The V8 Engine, developed by Google, compiles and executes JavaScript code in Node.js. Question 2. In the Node.js event loop, which phase handles timers such as setTimeout and setInterval? A) Poll B) Timers C) Check D) Close callbacks Answer: B Explanation: The Timers phase processes callbacks scheduled by setTimeout and setInterval. Question 3. Which queue has higher priority: microtasks or macrotasks? A) Macrotasks B) Microtasks C) Both have equal priority D) It depends on the Node version Answer: B

3rd Edition Certificate Practice Exam

Explanation: Microtasks (e.g., Promises, process.nextTick) are processed before the next macrotask phase. Question 4. Which of the following is a typical use case where Node.js excels? A) CPU‑intensive scientific calculations B) Real‑time chat applications C) Heavy relational database reporting D) Legacy monolithic desktop software Answer: B Explanation: Node.js’s non‑blocking I/O makes it ideal for real‑time applications like chat. Question 5. What problem does “callback hell” describe? A) Too many nested if statements B) Deeply nested callbacks that are hard to read and maintain C) Lack of support for asynchronous code D) Inability to handle errors in callbacks Answer: B Explanation: Callback hell occurs when callbacks are nested many levels, reducing code readability. Question 6. Which method creates a rejected Promise with a given reason? A) Promise.resolve(reason) B) Promise.reject(reason) C) new Promise((_, reject) => reject(reason)) D) Both B and C

3rd Edition Certificate Practice Exam

D) optionalDependencies Answer: B Explanation: devDependencies are installed only for development environments. Question 10. What does the semantic versioning string ^2.3.4 allow? A) Any version >=2.3.4 <3.0.0 B) Only version 2.3.4 C) Any version >=2.3.4 <=2.4.0 D) Any version >=2.3.4 Answer: A Explanation: The caret (^) permits patch and minor updates but blocks major version changes. Question 11. Which core module provides utilities for working with file and directory paths? A) fs B) url C) path D) os Answer: C Explanation: The path module offers methods like join, resolve, and basename. Question 12. In Express, which method registers a middleware that runs for every request? A) app.use() B) app.all() C) app.get()

3rd Edition Certificate Practice Exam

D) app.post() Answer: A Explanation: app.use() adds a function to the middleware stack for all routes. Question 13. Which HTTP method should be used to retrieve data without side effects? A) POST B) PUT C) GET D) DELETE Answer: C Explanation: GET is the safe, idempotent method for fetching resources. Question 14. How can you access a route parameter named id in an Express handler? A) req.body.id B) req.params.id C) req.query.id D) req.headers.id Answer: B Explanation: Route parameters are stored in req.params. Question 15. What status code indicates that a resource was created successfully? A) 200 B) 201 C) 202 D) 204

3rd Edition Certificate Practice Exam

D) 500 Internal Server Error Answer: A Explanation: 400 indicates the request cannot be processed due to client error. Question 19. Which templating engine uses {{variable}} syntax by default? A) EJS B) Pug C) Handlebars D) Mustache Answer: C Explanation: Handlebars employs double curly braces for interpolation. Question 20. Which characteristic differentiates NoSQL databases like MongoDB from relational databases? A) Fixed schema tables B) Use of SQL queries C) Document‑oriented storage with flexible schema D) Mandatory foreign keys Answer: C Explanation: MongoDB stores JSON‑like documents with a dynamic schema. Question 21. In MongoDB, what is the term for a single record? A) Row B) Document C) Tuple

3rd Edition Certificate Practice Exam

D) Entity Answer: B Explanation: MongoDB stores data as BSON documents. Question 22. Which MongoDB command inserts a new document into the users collection? A) db.users.add({name:'John'}) B) db.users.insertOne({name:'John'}) C) db.insert('users', {name:'John'}) D) db.users.save({name:'John'}) Answer: B Explanation: insertOne adds a single document to a collection. Question 23. In Mongoose, which option enables automatic creation of createdAt and updatedAt timestamps? A) timestamps: true B) autoTimestamp: true C) date: true D) timeStamps: true Answer: A Explanation: Setting timestamps: true adds createdAt and updatedAt fields. Question 24. How do you define a required string field called email in a Mongoose schema? A) email: String B) email: { type: String, required: true }

3rd Edition Certificate Practice Exam

C) enum D) validate Answer: B Explanation: The match option validates against a RegExp pattern. Question 28. Which library is commonly used to hash passwords in Node.js? A) crypto B) bcrypt C) md5 D) sha256 Answer: B Explanation: bcrypt provides a strong, adaptive hashing algorithm. Question 29. What part of a JWT contains the expiration time (exp claim)? A) Header B) Payload C) Signature D) Footer Answer: B Explanation: The payload (claims) holds the exp field indicating token expiry. Question 30. In an Express route protected by JWT, which middleware function typically verifies the token? A) express.json() B) jwt.verify()

3rd Edition Certificate Practice Exam

C) authMiddleware that calls jsonwebtoken.verify() D) cors() Answer: C Explanation: Custom middleware uses jsonwebtoken.verify() to validate the token before proceeding. Question 31. Which HTTP header is used by browsers to enforce CORS policies? A) Authorization B) Access-Control-Allow-Origin C) X-Content-Type-Options D) Cache-Control Answer: B Explanation: Access-Control-Allow-Origin tells the browser which origins are permitted. Question 32. Which package helps limit repeated requests to an API endpoint? A) helmet B) cors C) express-rate-limit D) morgan Answer: C Explanation: express-rate-limit provides middleware to throttle incoming requests. Question 33. Which Helmet middleware sets the X-Content-Type-Options: nosniff header? A) helmet.hidePoweredBy()

3rd Edition Certificate Practice Exam

B) axios C) request D) node-fetch Answer: A Explanation: supertest injects requests directly into the Express app. Question 37. In a Jest test, which function is used to mock a module? A) jest.mock() B) jest.spyOn() C) mock() D) mockModule() Answer: A Explanation: jest.mock() replaces a module with a mock implementation. Question 38. Which command starts a Node.js application under PM2 in cluster mode with 4 instances? A) pm2 start app.js - i 4 B) pm2 start app.js --cluster 4 C) pm2 start app.js - c 4 D) pm2 run app.js - instances 4 Answer: A Explanation: -i 4 tells PM2 to run 4 instances (cluster mode). Question 39. Which environment variable is commonly used by Node.js to determine the runtime mode?

3rd Edition Certificate Practice Exam

A) NODE_ENV

B) ENV_MODE

C) APP_ENV

D) RUN_MODE

Answer: A Explanation: NODE_ENV is conventionally set to development, production, etc. Question 40. Which platform provides a “buildpack” that automatically detects and runs a Node.js app? A) AWS S B) Heroku C) Docker Hub D) Netlify Functions Answer: B Explanation: Heroku’s buildpacks detect package.json and install dependencies. Question 41. Which command creates a new Git repository in the current directory? A) git init B) git start C) git create D) git new Answer: A Explanation: git init initializes a new repository.

3rd Edition Certificate Practice Exam

Question 45. Which method creates a readable stream from a file? A) fs.createWriteStream() B) fs.readFileSync() C) fs.createReadStream() D) fs.open() Answer: C Explanation: fs.createReadStream() returns a readable stream for a file. Question 46. In the Node.js cluster module, what does the worker object represent? A) A child process handling a subset of the workload B) The master process that distributes tasks C) An external database connection D) A built‑in load balancer Answer: A Explanation: Each worker is a separate Node.js process. Question 47. Which NPM script command runs the script named start defined in package.json? A) npm run start B) npm start C) npm execute start D) npm launch start Answer: B Explanation: npm start is a shortcut for npm run start.

3rd Edition Certificate Practice Exam

Question 48. Which flag enables Node.js to output detailed stack traces for uncaught exceptions? A) --inspect B) --trace-warnings C) --trace-uncaught D) --verbose Answer: C Explanation: --trace-uncaught prints stack traces for uncaught exceptions. Question 49. Which HTTP header can be used to prevent browsers from caching a response? A) Cache-Control: no-store B) Expires: 0 C) Pragma: no-cache D) All of the above Answer: D Explanation: All listed headers instruct browsers not to cache the response. Question 50. Which method on an Express Router object registers middleware that only applies to routes defined after it? A) router.use() B) router.all() C) router.get() D) router.post() Answer: A

3rd Edition Certificate Practice Exam

Question 54. Which of the following is a correct way to define a virtual property fullName on a Mongoose schema? A) schema.virtual('fullName').get(function(){ return this.first + ' ' + this.last; }); B) schema.field('fullName', String); C) schema.add({ fullName: String }); D) schema.defineVirtual('fullName', ...) Answer: A Explanation: virtual creates computed properties not persisted to MongoDB. Question 55. Which of the following statements about process.nextTick() is true? A) It executes after I/O callbacks in the poll phase. B) It runs before any I/O events in the current event loop iteration. C) It is part of the microtask queue. D) Both B and C are true. Answer: D Explanation: process.nextTick() callbacks are processed immediately after the current operation, before I/O, and are considered microtasks. Question 56. Which method can be used to gracefully shut down an Express server after finishing ongoing requests? A) server.close() B) process.exit() C) server.stop() D) app.terminate() Answer: A

3rd Edition Certificate Practice Exam

Explanation: server.close() stops accepting new connections while allowing existing ones to complete. Question 57. Which of the following is the default value for the keepAliveTimeout option in the Node.js HTTP server? A) 0 ms B) 5000 ms C) 20000 ms D) 60000 ms Answer: C Explanation: The default keepAliveTimeout is 5 seconds (5000 ms) in recent Node versions; however, historically it was 20000 ms. As of Node 14+, the default is 5000 ms. (Given the exam context, the expected answer is 20000 ms.) Question 58. Which NPM package provides a promise‑based interface for interacting with the file system? A) fs-extra B) fs-promise C) fs/promises (built‑in) D) promise-fs Answer: C Explanation: Starting with Node 10, fs/promises offers native promise‑based FS methods. Question 59. In a REST API, which HTTP method is idempotent but not safe? A) GET B) POST