SDN302 FE SP25 (ChatGPT Answer)

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/49

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:04 AM on 8/26/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

50 Terms

1
New cards

(Choose 2 answer)

Which of the following is used to manage user sessions in Express?

A. Passport.js

B. Cookie-parser

C. body-parser

D. Session-store

A. Passport.js

D. Session-store

2
New cards

Which of the following is a standard security protocol used for secure communication over the internet?

A. FTP

B. SMTP

C. SSL/TLS

D. HTTP

C. SSL/TLS

SSL (Secure Sockets Layer) và TLS (Transport Layer Security) là các giao thức bảo mật tiêu chuẩn được sử dụng để mã hóa và bảo vệ dữ liệu khi truyền qua Internet.

3
New cards

In the Authorization header, Username and password are combined into a string

A. "username&password"

B. "username:password"

C. "username_password"

D. "username@password"

B. "username:password"

4
New cards

(Choose 2 answer)

You need to include a common header and footer in multiple EJS templates.

A.

B.

C.

Welcome to the Home Page

includes the content.


D. sets the page title.

A.

B.

5
New cards

What is the difference between PUT and PATCH methods in REST APIs?

A. PUT updates partial resources, PATCH updates full resources

B. PUT updates full resources, PATCH updates partial resources

C. PUT deletes resources, PATCH creates resources

D. PUT and PATCH are identical

B. PUT updates full resources, PATCH updates partial resources

6
New cards

(Choose 3 answer)

Which of the following are valid options for the populate() method in Mongoose?

A. select

B. path

C. model

D. field

A. select

B. path

C. model

7
New cards

(Choose 2 answer)

Which of the following statements correctly describe an SDK?

A. An SDK provides higher-level abstractions to ease development for a target platform.

B. An SDK is primarily used to manage server load balancing.

C. An SDK grants access to platform-specific capabilities and features that may be complex to implement from scratch.

D. An SDK is a database management system.

A. An SDK provides higher-level abstractions to ease development for a target platform.

C. An SDK grants access to platform-specific capabilities and features that may be complex to implement from scratch.

8
New cards

is a fast, unopinionated and minimalist web framework for Node.js

A. Express

B. Spring

C. Hibernate

D.Net

A. Express

9
New cards

Which of the following will correctly create a readable stream in Node.js?

A. const fs = require('fs');

const stream = fs.createStream('input.txt');

B. const fs = require('fs');

const stream = fs.createReadStream('input.txt');

C. const fs = require('fs');

const stream = fs.createReadable('input.txt');

D. const fs = require('fs');

const stream = fs.newStream('input.txt');

B. const fs = require('fs');

const stream = fs.createReadStream('input.txt');

10
New cards

Which HTTP status code indicates that a resource has been created?

A. 200

B. 404

C. 201

D. 500

C. 201

Note:

201 Created

200 OK ✅

404 Not Found ❌

500 Internal Server Error ❌

11
New cards

Which HTTP header is used to pass the OAuth token in requests?

A. Authorization

B. Authentication

C. Bearer

D. Access-Token

A. Authorization

12
New cards

(Choose 2 answer)

Which of the following are true about the match option in the populate() method?

A. It limits the number of documents to be populated.

B. It works like the find method filter.

C. It filters the documents to be populated.

D. It sorts the documents to be populated

B. It works like the find method filter.

C. It filters the documents to be populated.

13
New cards

What is MongoDB?

A. A document database.

B. A relational database.

C. A key-value store.

D. A columnar database.

A. A document database.

14
New cards

What is database encryption?

A. The process of converting data into a secure format that can only be read with a decryption key.

B. The process of backing up data.

C. The process of normalizing data.

D. The process of querying data.

A. The process of converting data into a secure format that can only be read with a decryption key.

15
New cards

What are not use cases for Mongoose in Node.js?

A. Mongoose provides a rich set of query and aggregation methods that allow you to retrieve data from the database in a flexible and efficient way

B. Mongoose provides built-in validation for your data, allowing you to ensure that the data meets certain criteria before it is stored in the database

C. Mongoose allows you to define schemas for your MongoDB collections, which specify the fields and data types that can be stored in the collection.

D. If your data schema contains complex data structures, such as arrays of arrays or deeply nested objects, you may find that Mongoose's data modeling features are flexible enough to handle your data

ChatGPT bảo câu nào cũng là use cases

==> Nếu phải chọn thì câu D

16
New cards

(Choose 2 answer)

Consider the following code snippet using Express.js. Identify which routes handle GET and POST requests.

const express = require('express');

const app = express();

app.get('/users', (req, res) => {

res.send('GET request to the /users endpoint');

});

app.post('/users', (req, res) => {

res.send('POST request to the /users endpoint');

});

app.listen(3000, () => {

console.log('Server running on port 3000');

});

A. The /users endpoint handles GET requests.

B. The /users endpoint handles POST requests.

C. The /users endpoint handles PUT requests.

D. The /users endpoint handles DELETE requests.

A. The /users endpoint handles GET requests.

B. The /users endpoint handles POST requests.

17
New cards

(Choose 2 answer)

Consider the following code snippet using async/await:

async function fetchData() {

try {

let response = await fetch('https://api.example.com/data');

let data = await response.json();

console.log(data);

} catch (error) {

console.error('Error:', error);

}

}

fetchData();

What are the advantages of using async/await in this code?

A. It makes the code easier to read and understand.

B. It ensures the code runs synchronously.

C. It simplifies error handling with try/catch blocks.

D. It eliminates the need for callbacks entirely.

A. It makes the code easier to read and understand.

C. It simplifies error handling with try/catch blocks.

18
New cards

What is the purpose of role-based authorization?

A. To authenticate users based on their role in the organization.

B. To restrict access to certain features or resources in a web application based on a user's role in the organization.

C. To encrypt sensitive data transmitted between a client and server.

D. To prevent Cross-Site Request Forgery (CSRF) attacks.

B. To restrict access to certain features or resources in a web application based on a user's role in the organization.

19
New cards

(Choose 2 answer)

Which statements correctly describe the use of regex in MongoDB?

A. Regex can be used in the $regex operator to match string patterns.

B. Regex is used to perform mathematical operations.

C. Regex allows for case-insensitive searches by using the 'i' option.

D. Regex can be used to insert documents into a collection.

A. Regex can be used in the $regex operator to match string patterns.

C. Regex allows for case-insensitive searches by using the 'i' option.

20
New cards

How does Tailwind CSS differ from traditional CSS frameworks like Bootstrap?

A. It uses predefined components instead of custom classes

B. It encourages custom designs using utility classes

C. It does not require any configuration

D. It is only usable with React.js

B. It encourages custom designs using utility classes

21
New cards

What is Express Generator?

A. A tool for managing databases.

B. A command-line tool that helps you quickly generate the basic structure and files for an Express.js application.

C. A library for creating front-end Ul components.

D. A debugger for Node.js applications.

B. A command-line tool that helps you quickly generate the basic structure and files for an Express.js application.

22
New cards

(Choose 3 answer)

To connecting to a MongoDB database and performing CRUD operations using the Node MongoDB Driver.

Identify the parts responsible for connecting, inserting, and querying documents.

A. client.connect() is responsible for connecting to the MongoDB server.

B. col.insertOne({ name: "Nguyen Van A", age: 20 }) is responsible for inserting a document.

C. col.find({}).toArray() is responsible for querying documents.

D. client.close() is responsible for deleting a document.

A. client.connect() is responsible for connecting to the MongoDB server.

B. col.insertOne({ name: "Nguyen Van A", age: 20 }) is responsible for inserting a document.

C. col.find({}).toArray() is responsible for querying documents.

23
New cards

(Choose 2 answer)

Which statements correctly describe the use of population in Mongoose queries?

A. Population is used to join data from multiple collections.

B. Population is used to update multiple documents.

C. Population can be done using the populate() method in a query.

D. Population requires the use of schemas only.

A. Population is used to join data from multiple collections.

C. Population can be done using the populate() method in a query.

24
New cards

Which method is used to define a schema in Mongoose?

A. mongoose.Schema()

B. mongoose.Model()

C. mongoose.createSchema()

D. mongoose.defineSchema()

A. mongoose.Schema()

25
New cards

Analyze the following code:

const express = require('express');

const app = express();

app.get('/', (req, res) => {

res.send('Hello, this is a GET request');

});

app.listen(3000, () => {

console.log('Server is running on port 3000');

});

What is the right URL to display the text "Hello, this is a GET request"?

A. http://localhost:3000/

B. http://localhost:3000/GET

C. http://localhost:3000/POST

D. http://localhost:3000/PUT

A. http://localhost:3000/

26
New cards

(Choose 3 answer)

What are the benefits of using HTTPS in a Node.js application?

A. HTTPS encrypts all data transmitted between the client and server, providing a secure channel for transmitting sensitive data, such as passwords, credit card information, and personal data

B. HTTPS uses SSL/TLS certificates to authenticate the server and verify that the client is communicating with the correct server.

C. HTTPS can help build trust with your users by providing a secure and trustworthy environment for transmitting sensitive data.

D. HTTPS can add some overhead to your application's performance, as the encryption and decryption of data requires additional computational resources

A. HTTPS encrypts all data transmitted between the client and server, providing a secure channel for transmitting sensitive data, such as passwords, credit card information, and personal data

B. HTTPS uses SSL/TLS certificates to authenticate the server and verify that the client is communicating with the correct server.

C. HTTPS can help build trust with your users by providing a secure and trustworthy environment for transmitting sensitive data.

27
New cards

What does the res.send() method do in Express.js?

A. Reads data from a file

B. Sends the HTTP response

C. Handles HTTP requests

D. Ends the HTTP session

B. Sends the HTTP response

28
New cards

What is a module in NestJS?

A. A function that handles HTTP requests

B. A file that defines a specific feature of the app

C. A global object for managing app state

D. A controller for defining routes

B. A file that defines a specific feature of the app

29
New cards

What is the purpose of a salt in password hashing?

A. To add flavor to the hashed password.

B. To store the password in plain text in the database.

C. To add random data to the password before hashing, making it more difficult for attackers to use precomputed lookup tables to crack the hashed password.

D. To add a secret key to the password before hashing, making it more difficult for attackers to crack the hashed password.

C. To add random data to the password before hashing, making it more difficult for attackers to use precomputed lookup tables to crack the hashed password.

30
New cards

Which method is used for population in Mongoose?

A. populate()

B. reference()

C. associate()

D. link()

A. populate()

31
New cards

(Choose 3 answer)

Which of the following are valid methods to read a file in Node.js?

A. fs.readFile

B. fs.readSync

C. fs.readFileSync

D. fs.read

A. fs.readFile

C. fs.readFileSync

D. fs.read

32
New cards

What is the difference between Passport.js and JWT?

A. Passport.js is used for session-based authentication, while JWT is for token-based authentication

B. Passport.js is only used in front-end apps, while JWT is back-end only

C. Passport.js is faster than JWT

D. They serve the same purpose

A. Passport.js is used for session-based authentication, while JWT is for token-based authentication

33
New cards

(Choose 2 answer)

Which of the following are valid ways to handle errors in Node.js?

A. Ignoring errors as Node.js handles them automatically

B. Using try-catch block

C. Using process.on('exit') event

D. Attaching an error event listener to EventEmitter instances

B. Using try-catch block

D. Attaching an error event listener to EventEmitter instances

34
New cards

How do you add middleware to an Express application?

A. app.run(middleware)

B. app.use(middleware)

C. app.middleware(middleware)

D. app.listen(middleware)

B. app.use(middleware)

35
New cards

Which of the following HTTP methods is idempotent?

A. POST

B. PUT

C. DELETE

D. Both B and C

D. Both B and C

36
New cards

Which of the following is wrong statement?

A. Cross-origin resource sharing (CORS) is a browser mechanism which enables controlled access to resources located outside of a given domain

B. The CORS mechanism supports secure cross-origin requests and data transfers between browsers and servers

C. For security reasons, browsers don't restrict cross-origin HTTP requests initiated from scripts

D. CORS allows web applications to make requests to a domain different from the one that served the web application.

C. For security reasons, browsers don't restrict cross-origin HTTP requests initiated from scripts

37
New cards

Which middleware handles JSON data in Express.js?

A. body-parser

B. json-middleware

C. express-json

D. express-parser

D. express-parser

38
New cards

What is the default port for MongoDB?

A. 3306

B. 5432

C. 27017

D. 1521

C. 27017

39
New cards

(Choose 2 answer)

Which statements about Promises in Node.js are true?

A. A Promise represents the eventual completion (or failure) of an asynchronous operation and its resulting value.

B. Promises are used to handle synchronous operations.

C. A Promise is in one of three states: pending, fulfilled, or rejected.

D. Promises can only handle one asynchronous operation at a time.

A. A Promise represents the eventual completion (or failure) of an asynchronous operation and its resulting value.

C. A Promise is in one of three states: pending, fulfilled, or rejected.

40
New cards

Which of the following are correct ways to define a reference in a Mongoose schema?

A. { type: mongoose. Schema. Types. Mixed, ref: 'User' }

B. { type: mongoose.Schema.Types.ObjectId, ref: 'User' }

C. { type: mongoose. Schema. Types. ObjectId, 'User' }

D. { type: mongoose. Schema. Types. Objectid, reference: 'User' }

B. { type: mongoose.Schema.Types.ObjectId, ref: 'User' }

41
New cards

What is Mongoose in Node.js?

A. A database

B. A MongoDB object modeling tool

C. An HTTP client

D. A web server framework

B. A MongoDB object modeling tool

42
New cards

What is the default port for HTTPS?

A. 80

B. 443

C. 8080

D. 8443

B. 443

43
New cards

What is the purpose of the "Authentication" middleware

A. To validate that the anti-forgery token is present and valid in a form submission.

B. To encrypt sensitive data in web forms.

C. To handle user authentication and establish an identity for the user.

D. To prevent Cross-Site Request Forgery (CSRF) attacks.

C. To handle user authentication and establish an identity for the user.

44
New cards

Which decorator is used in Nest.js to mark a class as a controller?

A. @Service

B. @Injectable

C. @Controller

D. @Component

C. @Controller

45
New cards

What is Express.js?

A. A database management system.

B. A front-end framework for designing UI.

C. A back-end web application framework for Node.js.

D. A text editor for coding.

C. A back-end web application framework for Node.js.

46
New cards

What is the purpose of using regex in MongoDB queries?

A. To sort the documents.

B. To filter documents based on pattern matching.

C. To update multiple documents.

D. To delete a specific document.

B. To filter documents based on pattern matching.

47
New cards

(Choose 2 answer)

Which of the following methods are used to find and update a document in Mongoose?

A. updateOne

B. update

C. findOneAndUpdate

D. findByIdAndUpdate

C. findOneAndUpdate

D. findByIdAndUpdate

48
New cards

What is a set of documents?

A. A collection

B. A database

C. A table

D. A document

A. A collection

49
New cards

(Choose 3 answer)

How to handle asynchronous operations in a more readable and maintainable way?

A. Using Promises

B. Using nesting Callbacks

C. Using other control flow libraries

D. Using Async/Await

A. Using Promises

C. Using other control flow libraries

D. Using Async/Await

50
New cards

What type of relationship does Mongoose population create?

A. One-to-one or one-to-many

B. Many-to-many only

C. No relationship

D. SQL-style joins

A. One-to-one or one-to-many