




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The JSNSD Exam validates advanced skills in creating and managing RESTful and network services using Node.js. It includes topics like Express, API authentication, HTTP handling, security, error management, and modern service-oriented design. Candidates must demonstrate real-world proficiency in back-end service delivery, focusing on performance, modularity, and maintainability in production environments.
Typology: Exams
1 / 118
This page cannot be seen from the preview
Don't miss anything!





























































































Question 1. What is the primary advantage of Node.js's event-driven, non- blocking I/O model? A) Simplifies multithreading B) Improves CPU-bound task performance C) Enables handling multiple concurrent operations efficiently D) Ensures sequential execution of code Answer: C Explanation: Node.js's event-driven, non-blocking I/O allows it to handle many concurrent operations simultaneously without waiting, making it highly efficient for I/O-bound tasks. Question 2. Which module system does Node.js traditionally use? A) AMD B) CommonJS C) ES Modules D) UMD Answer: B Explanation: Node.js originally adopted the CommonJS module system, which uses require() and module.exports for module management.
Question 3. In Node.js, what is the purpose of the package.json file? A) To configure the server B) To manage dependencies, scripts, and project metadata C) To store environment variables D) To define database schemas Answer: B Explanation: package.json includes project metadata, dependencies, scripts, and configuration details necessary for managing a Node.js project. Question 4. Which Node.js core module provides an interface for working with file streams? A) http B) fs C) stream D) net Answer: C Explanation: The stream module in Node.js facilitates working with streaming data, enabling efficient reading and writing of files and data flows.
Question 7. What is Express.js primarily used for in Node.js development? A) Database management B) Building server-side web applications and APIs C) Managing dependencies D) Handling file uploads Answer: B Explanation: Express.js is a minimal web framework for Node.js, simplifying the development of server-side applications and RESTful APIs. Question 8. Which middleware function in Express.js is used to parse incoming JSON request bodies? A) express.urlencoded() B) express.json() C) bodyParser() D) parseRequest() Answer: B Explanation: express.json() middleware parses incoming JSON payloads, enabling easy access to request data.
Question 9. Which HTTP status code typically indicates successful resource creation? A) 200 B) 201 C) 400 D) 404 Answer: B Explanation: Status code 201 indicates that a new resource has been successfully created. Question 10. Which database type is MongoDB classified as? A) Relational database B) NoSQL document-oriented database C) Key-value store D) Graph database Answer: B Explanation: MongoDB is a NoSQL database that stores data in flexible, JSON- like documents.
Question 13. Which method is used to handle multiple promises concurrently in Node.js? A) Promise.all() B) Promise.race() C) Promise.resolve() D) Both A and B Answer: D Explanation: Promise.all() waits for all promises to settle, while Promise.race() resolves or rejects as soon as any promise does. Question 14. What is the purpose of Node.js's EventEmitter class? A) To handle HTTP requests B) To manage custom events and event-driven programming C) To handle database connections D) To manage process signals Answer: B Explanation: EventEmitter allows creating and handling custom events, facilitating event-driven programming in Node.js.
Question 15. How does Node.js execute code in terms of the event loop? A) Synchronously B) In phases with specific tasks like timers, I/O callbacks, and check C) Randomly D) Only once at startup Answer: B Explanation: The event loop runs in phases, handling timers, I/O callbacks, idle, poll, check, and close callbacks to manage asynchronous operations. Question 16. Which security vulnerability involves injecting malicious scripts into web pages? A) SQL injection B) Cross-site scripting (XSS) C) Cross-site request forgery (CSRF) D) Man-in-the-middle attack Answer: B Explanation: XSS involves injecting malicious scripts into web pages viewed by other users, leading to security breaches.
Question 19. Which architecture pattern involves building applications as a collection of loosely coupled microservices? A) Monolithic architecture B) Microservices architecture C) Layered architecture D) Client-server architecture Answer: B Explanation: Microservices architecture divides applications into independent, modular services that communicate over network protocols. Question 20. Which protocol is commonly used for inter-service communication in microservices architectures? A) REST over HTTP B) gRPC C) WebSockets D) All of the above Answer: D Explanation: Microservices can communicate via REST over HTTP, gRPC, WebSockets, and other protocols, depending on requirements.
Question 21. Which message broker is often used in microservices for asynchronous messaging? A) Kafka B) RabbitMQ C) Redis D) All of the above Answer: D Explanation: Kafka, RabbitMQ, and Redis are popular message brokers facilitating decoupled, asynchronous communication. Question 22. What is the primary purpose of containerization tools like Docker in Node.js deployment? A) To virtualize hardware B) To package applications and dependencies for consistent deployment C) To replace cloud providers D) To improve code performance Answer: B Explanation: Docker containers encapsulate applications and dependencies, ensuring consistent environments across development and production.
Question 25. Which strategy helps optimize database query performance in Node.js applications? A) Using raw SQL exclusively B) Connection pooling and indexing C) Disabling caching D) Avoiding transactions Answer: B Explanation: Connection pooling reduces connection overhead, and indexing improves query speed, optimizing database performance. Question 26. What is the role of PM2 in Node.js deployment? A) To manage process lifecycle and clustering B) To serve static files C) To monitor database performance D) To generate API documentation Answer: A Explanation: PM2 is a process manager that simplifies process management, clustering, and monitoring of Node.js applications.
Question 27. Which Node.js feature enables handling large data streams efficiently? A) Buffers B) Streams C) Promises D) Callbacks Answer: B Explanation: Streams handle data piece-by-piece, which is ideal for processing large files or real-time data efficiently. Question 28. How does Node.js handle concurrency? A) Multi-threading via worker threads B) Single-threaded with event loop and asynchronous I/O C) Multi-process clustering only D) Sequential execution Answer: B Explanation: Node.js uses a single-threaded event loop with asynchronous I/O to handle multiple concurrent operations efficiently.
Question 31. Which HTTP status code indicates unauthorized access? A) 401 B) 403 C) 404 D) 500 Answer: A Explanation: 401 Unauthorized indicates that authentication is required or has failed. Question 32. In Node.js, what is the purpose of the 'cluster' module? A) To manage database connections B) To enable multi-core CPU utilization by creating worker processes C) To handle HTTP requests D) To facilitate messaging between services Answer: B Explanation: The 'cluster' module allows spawning multiple worker processes for better CPU utilization and scalability.
Question 33. Which package is used for mocking in testing Node.js applications? A) Mocha B) Chai C) Sinon D) Supertest Answer: C Explanation: Sinon provides mocks, stubs, and spies to facilitate unit testing. Question 34. Which command initializes a new Node.js project? A) npm start B) npm init C) node create D) npm install Answer: B Explanation: 'npm init' creates a new package.json file, initializing a Node.js project.
Question 37. What does the 'async/await' syntax in JavaScript provide? A) Synchronous code execution B) Syntactic sugar over promises for cleaner asynchronous code C) Multithreading capabilities D) Automatic error handling without try-catch Answer: B Explanation: async/await simplifies promise-based asynchronous code, making it more readable and maintainable. Question 38. Which Node.js package is typically used for logging? A) Winston B) bcrypt C) Express D) Mongoose Answer: A Explanation: Winston is a popular logging library for Node.js, supporting multiple transports and log levels.
Question 39. Which HTTP status code signifies a client-side error? A) 200 B) 400 C) 500 D) 302 Answer: B Explanation: 400 Bad Request indicates a client-side error in request syntax or parameters. Question 40. Which is a recommended practice for handling sensitive data in Node.js applications? A) Hardcoding passwords B) Using environment variables C) Storing in source code D) Embedding in client-side code Answer: B Explanation: Environment variables keep sensitive data like API keys and passwords out of source code, enhancing security.