First Semester
CROSS-PLATFORM SCRIPT DEVELOPMENT TECHNOLOGY
Final Exam
2023-2024
Name: ________________________ Course & Year: _____________ Date: ____________ Score: ___
Test I: Multiple Choice
Direction: Read each question carefully. Choose the letter of the correct answer and write it in the provided space.
1. What is Node.js?
a) A programming language
b) A framework
c) A runtime environment
d) A text editor
2. Which of the following is the correct way to install Node.js modules?
a) node install module_name
b) npm install module_name
c) install module_name
d) node get module_name
3. What is the default port number for a Node.js application?
a) 8080
b) 3000
c) 5000
d) 80
4. Which core module is used for creating web servers in Node.js?
a) HTTP
b) FS
c) Path
d) OS
5. What is the function used to create a server in Node.js?
a) http.listen()
b) http.createServer()
c) server.listen()
d) server.create()
6. How can you read a file asynchronously in Node.js?
a) fs.readFile()
b) fs.readFileSync()
c) fs.open()
d) fs.getFile()
7. Which of the following is true about Node.js?
a) It runs in the browser.
b) It is single-threaded.
c) It only supports JavaScript.
d) It can only handle static content.
8. How do you handle exceptions in Node.js?
a) Using try-catch
b) Using throw-catch
c) Using setTimeout
d) Using fs-catch
9. What is the global object used in Node.js to represent the current module?
a) module.exports
b) exports
c) require
d) global.module
10. What is process.env in Node.js?
a) A method to execute environment variables
b) A property that contains information about the environment variables
c) A function to modify environment configurations
d) A constant to set up configurations
11. Which of the following is used to load external modules in Node.js?
a) load()
b) import()
c) require()
d) include()
12. What is the use of next() in Express.js?
a) To terminate the current middleware
b) To pass control to the next middleware
c) To skip error handling
d) To return a response immediately
13. What is the Node.js event-driven model?
a) A model where everything is handled synchronously
b) A model that responds to system events
c) A model based on asynchronous I/O operations
d) A model that only allows single events
14. Which Node.js core module is used for handling streams?
a) Stream
b) HTTP
c) Path
d) Events
15. Which statement about Node.js Buffer objects is correct?
a) Buffers are used to manipulate binary data.
b) Buffers store file paths.
c) Buffers can only store JSON data.
d) Buffers are not supported in Node.js.
16. What does the method fs.writeFileSync() do?
a) Reads a file synchronously.
b) Writes a file synchronously.
c) Deletes a file synchronously.
d) Appends data to a file synchronously.
17. What does npm stand for?
a) Node Package Manager
b) Node Programming Module
c) Node Process Manager
d) None of the above
18. What is the purpose of the "package.json" file in a Node.js project?
a) To store project dependencies
b) To configure the HTTP server
c) To define global variables
d) To store runtime environment details
19. How do you start a Node.js application?
a) run app.js
b) start app.js
c) node app.js
d) execute app.js
20. Which of the following is NOT a core module in Node.js?
a) Events
b) Util
c) fs
d) Lodash
21. Which statement about middleware in Express.js is true?
a) Middleware is used only for error handling.
b) Middleware is optional and cannot alter requests.
c) Middleware functions execute in sequence.
d) Middleware must always terminate the request.
22. What does the "path" module do in Node.js?
a) Handles HTTP requests.
b) Parses and manages file paths.
c) Reads JSON data.
d) Manages event loops.
23. What is the use of the "querystring" module in Node.js?
a) Handles URL query strings.
b) Parses XML data.
c) Manages user sessions.
d) Reads JSON objects.
24. Which command is used to initialize a new Node.js project?
a) npm start
b) npm install
c) npm init
d) npm create
25. Which of the following HTTP methods are commonly used in REST APIs?
a) GET, POST, PUT, DELETE
b) FETCH, UPDATE, DELETE, LIST
c) SAVE, ADD, DELETE, REMOVE
d) CREATE, READ, UPDATE, DELETE
26. What does the "os" module in Node.js provide?
a) Utilities for interacting with the operating system
b) Functions for handling HTTP requests
c) Tools for parsing URLs
d) Methods for managing file systems
27. What does the method fs.unlink() do?
a) Links two files together
b) Deletes a file
c) Reads a file asynchronously
d) Renames a file
28. What is a middleware function in Express.js?
a) A function to perform database queries
b) A function to modify requests and responses
c) A function to initialize a server
d) A function to handle file uploads
29. What is the purpose of res.send() in Express.js?
a) Sends a JSON response
b) Sends a file to the client
c) Sends an HTTP response
d) Ends the middleware chain
30. What does res.json() do in Express.js?
a) Parses JSON data
b) Sends a JSON response
c) Logs data to the console
d) Reads JSON files
Test II (True or False): Read each statement carefully. Write T if the statement is true, and F if the statement is
false.
31. Node.js is a single-threaded runtime environment. ______
32. The "events" module is used for working with the file system. ______
33. Node.js applications run on the client side. ______
34. The "util" module provides utility functions. ______
35. A Promise in Node.js is used for handling asynchronous operations. ______
36. Express.js is a core module in Node.js. ______
37. Node.js uses the V8 JavaScript engine. ______
38. You can use require() to load JSON files directly in Node.js. ______
39. The HTTP module is used for building APIs in Node.js. ______
40. fs.writeFile() writes data synchronously to a file. ______
41. Node.js is event-driven and non-blocking by design. ______
42. The process object in Node.js provides information about the current Node.js process. ______
43. npm is a package manager for JavaScript libraries. ______
44. console.log() is not available in Node.js. ______
45. Streams in Node.js allow reading and writing data in chunks. ______
46. Middleware in Express.js can terminate requests if needed. ______
47. Modules in Node.js can be imported using the import statement by default. ______
48. Node.js can only work with static websites. ______
49. The path module can be used to join and resolve file paths. ______
50. setTimeout() is a Node.js function for asynchronous delays. ______