Viva Questions

INT222 50 Questions
Unit I Getting Started with Node.JS
1
Node.js is described as single-threaded. If that is the case, how does it handle concurrent requests efficiently without blocking the main thread?
Unit I NPM modules
2
What is the specific purpose of the 'package-lock.json' file, and how does it differ from 'package.json'?
Unit I EventEmitter in Node.js
3
Scenario: You have an EventEmitter with multiple listeners for the same event. If one listener throws an error, what happens to the subsequent listeners?
Unit I Handling Data I/O (Stream Module)
4
Why would you choose 'fs.createReadStream' over 'fs.readFile' when serving a large video file to a client?
Unit I Handling Data I/O (Zlib)
5
Explain the concept of 'piping' in the context of Streams and Zlib.
Unit I Promises and async/await
6
If you use 'await' inside a loop (e.g., a for-loop) versus using 'Promise.all' with map, how does the execution behavior differ?
Unit I REPL
7
Beyond simple calculations, what is a practical use case for the Node.js REPL during the development phase?
Unit I Handling Data I/O (fs module)
8
What is the difference between 'fs.writeFile' and 'fs.appendFile'? What happens if the specified file does not exist in both cases?
Unit II Implementing HTTP Services
9
In the native HTTP module, what is the significance of the 'response.end()' method?
Unit II Request and Response objects
10
Where does the data reside when a client sends JSON data via a POST request in a native Node.js HTTP server (without Express)?
Unit II Setting response headers
11
Why is it important to set the 'Content-Type' header to 'application/json' when sending a JSON response?
Unit II Basic Websites With Node.JS (Express)
12
What is the primary advantage of using 'express.Router' in a large application?
Unit II body-parser
13
If you forget to include body-parser (or the built-in express.json middleware) in your Express app, what will be the value of 'req.body' on a POST request?
Unit II Status codes
14
Distinguish between HTTP status codes 200 and 201.
Unit II express validator
15
In an Express route handler, you have validation middleware. If the validation fails, does the request automatically stop?
Unit II HTTP Methods
16
From an architectural standpoint, why should GET requests not be used to modify data on the server?
Unit III Socket Services (WebSocket)
17
How does the communication protocol of a WebSocket differ from a standard HTTP request?
Unit III Socket.IO Chat Server
18
In Socket.IO, what is the difference between 'socket.emit()' and 'io.emit()'?
Unit III Socket.IO Broadcast
19
Scenario: A user joins a chat room. How do you send a 'User Joined' message to everyone except the user who just joined?
Unit III Creating middlewares
20
What are the three arguments passed to a standard middleware function in Express, and what is the role of the third one?
Unit III app.use() vs app.all()
21
Compare 'app.use("/api", ...)' and 'app.all("/api", ...)'.
Unit III cookie-parser
22
What is the security risk of storing sensitive data (like a user's role or ID) directly in a cookie without signing or encryption?
Unit III express-session vs cookie-session
23
Architecture-wise, what is the main difference between 'express-session' and 'cookie-session'?
Unit III Middleware Execution
24
If you define an error-handling middleware function, how many arguments must it accept for Express to recognize it as an error handler?
Unit IV MongoDB Terminology
25
What is the relationship between a Collection and a Document in MongoDB?
Unit IV MongoDB Shell Commands
26
Which shell command would you use to remove a specific collection named 'users' from the database?
Unit IV Data Manipulation (Update)
27
In MongoDB, what is the difference between 'updateOne' and 'replaceOne'?
Unit IV Introduction to Mongoose
28
Since MongoDB is schema-less, why do we use Mongoose Schemas in Node.js applications?
Unit IV Mongoose Models
29
What does a Mongoose 'Model' represent in your code?
Unit IV Connect MongoDB using Node.js
30
Why is the database connection logic usually asynchronous, and how do you handle server startup relative to this connection?
Unit IV CRUD Operations
31
When finding a document by ID in Mongoose, which method is most efficient/convenient?
Unit IV MongoDB Update Operators
32
What does the '$push' operator do in a MongoDB update operation?
Unit V Introduction to PostgreSQL
33
How does PostgreSQL differ fundamentally from MongoDB regarding data structure?
Unit V Basic SQL commands
34
What is the SQL command to create a new table named 'students' with columns for 'id' and 'name'?
Unit V CRUD operations (SQL)
35
In SQL, what is the difference between the 'DELETE' command and the 'TRUNCATE' command?
Unit V SQL Queries
36
Which SQL clause is used to filter records?
Unit V PostgreSQL Installation/Setup
37
When connecting Node.js to PostgreSQL, what is a 'Connection Pool' and why is it recommended?
Unit V SQL Update
38
What happens if you run an UPDATE statement in SQL without a WHERE clause?
Unit VI Testing RestAPI
39
When testing a REST API, why is it important to mock external services or databases?
Unit VI Testing RestAPI
40
What are the two primary things you check when asserting a test response for an API endpoint?
Unit VI Deployment with GitHub
41
What is the role of CI/CD (Continuous Integration/Continuous Deployment) when deploying via GitHub?
Unit VI Third party rendering
42
What is the main SEO (Search Engine Optimization) benefit of Server-Side Rendering (Third party rendering) over Client-Side Rendering?
Unit VI Deployment
43
Why should you never commit your '.env' file to GitHub?
Unit VI Deployment
44
What is 'Process Management' (e.g., PM2) in the context of Node.js deployment?
General/Practical Course Outcome CO1
45
Explain the difference between blocking and non-blocking code in Node.js with a real-world analogy.
General/Practical Course Outcome CO2
46
What is the difference between a URL Parameter and a Query String in Express routing?
General/Practical Course Outcome CO3
47
In a Socket.IO application, what is a 'Room'?
General/Practical Course Outcome CO4
48
Why is 'Validation' technically unnecessary in MongoDB but crucial in Mongoose?
General/Practical Course Outcome CO5
49
When would you choose PostgreSQL over MongoDB for a specific project?
General/Practical Course Outcome CO6
50
What is the purpose of 'Regression Testing' before deployment?