WorksheetsSummary of Questions & Answers (Midterm WPR)
Total questions: 100
Worksheet time: 53mins
What is the correct HTML for creating a hyperlink?
Which middleware in Express.js helps in handling JSON data from POST requests?
express.urlencoded()
express.parse()
express.data()
express.json()
In the context of the GET method, what type of data format can the response typically be returned as?
HTML/XML
CSV/JSON
TXT/CSV
XML/JSON
What does the
Content to display if scripting is disabled
Script to be run if scripting is enabled
No script content allowed in the document
No script content is allowed in the section
How to send a urlencoded POST request with fetch?
fetch(URL, {method: 'POST', 'Content-Type': 'application': 'x-www-form-urlencoded'})
fetch(URL, {method: 'POST', 'Content-Type': 'application/x-www-form-urlencoded'})
fetch(URL, {method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
fetch(URL, {method: 'POST', headers: {'Content-Type': 'application/x-www-form-urlencoded'}})
Which property specifies the space inside the border of an element?
content-spacing
margin
spacing
padding
Use the correct Math method to get the square root of 9. Fill in the blank: ________
sqrt(9)
pow(9,2)
abs(9)
round(9)
Write the CSS to add a background color of #ececec for all
elements.
h1{background-color:#ececec;}
h1{color:#ececec;}
h1{background:#ececec;}
h1{background-color:h1;}
How do you specify the spacing between columns in a multi-column layout?
gap
column-space
column-spacing
column-gap
How do you make an element's text not wrap and stay on one line?
white-space: no-wrap;
text-wrap: nowrap;
text-overflow: nowrap;
white-space: nowrap;
What value is logged to the console?
36
12
18
24
What is the configuration file that contains a Node.js project's dependencies?
package.json
config.json
manifest.json
pom.xml
The next() function in Express middleware is used to:
Pass control to the next middleware function
Send a response to the client
Terminate the server process
Log request details
What is the output if the button is not clicked within 5 seconds?
Option A
Option B
How do you create a transition effect in CSS?
transform
transition-effect
transition
animation
Which property is used to control the order of flex items?
item-order
order
flex-order
flex-item-order
Which tag is used to define a section that contains content aside from the main content in HTML5?
Which tag pair configures a structural area on a web page?
What key feature of Node.js is crucial for building REST APIs?
Access to the DOM
Managing HTTP requests and server-side functionality
Handling client-side events
File management
In browser JavaScript, what object is assumed to exist and it is not necessary to include it as an object when referring to its methods and properties?
window
document
console
navigator
How do you send a status of 404 and a message "Not Found" in Express?
res.status(404).send('Not Found')
res.send(404, 'Not Found')
res.sendStatus(404, 'Not Found')
res.statusCode(404).send('Not Found')
In an e-commerce application, the POST request is typically used for:
Placing an order
Deleting an account
Updating user information
Fetching product details
Complete the following statement to print out the average age. console.log(obj["average-age"] );
average-age
avg-age
mean-age
averageAge
How can you connect a module to another in Node.js?
Tunnel
Pipeline
Expose
Exports
Which of the following will assign the value 5 to the variable productCost?
productCost = 5;
productCost == 5;
productCost := 5;
productCost => 5;
How do you run a Node.js file from the command line?
node
npm run
run
node start
Which property is used to change the font of an element?
font-weight
font-style
font-face
font-family
What value is logged to the console?
6
3
12
0
In JavaScript, how do you display an alert box with the text "Hello World"?
alert ("Hello World");
msg ("Hello World");
alertBox ("Hello World");
msgBox ("Hello World");
Which of the following configures a background color of #00CED1 for a web page using CSS?
body {background-color: #00CED1;}
document {bgcolor: #00CED1;}
document {background: #00CED1;}
body {bgcolor: #00CED1;}
Finish the following code to send a POST request using fetch (do not add any unnecessary spaces) let params = new FormData(id("input-form")); fetch (url, { })
method: "POST", body: params
method: "GET", body: params
method: "POST", params: body
body: params, method: "GET"
Which of the following modules is used to create a HTTP server?
fs
express
multer
nodemon
How do you make an element take up only the minimum width it needs?
width: auto;
width: max-content;
width: min-content;
width: fit-content;
Execute myFunction when user clicks on the
addEventListener
setTimeout
querySelector
getElementById
What is the output of the code above?
3 1 2
1 2 3
2 3 1
How do you make an image responsive in CSS?
max-height: 100%;
width: 200px;
border: 1px solid;
font-size: 2em;
Convert the text into an UPPERCASE text: let txt = "Hello World!"; txt = txt.__________ ; Fill in the blank to convert the text to uppercase.
toUpperCase()
toLowerCase()
capitalize()
makeUpperCase()
How to send a urlencoded POST request with fetch?
fetch (URL, {method: 'POST', 'Content-Type': '{application,}})
fetch (URL, {'method': 'POST','Content-Type': 'application,})
fetch (URL, {'method': 'POST', headers: [Content-Type: application]})
fetch (URL, {'method': 'POST', headers: {'Content-Type': 'application'}})
In the context of the GET method, what type of data format can the response typically be returned as?
TXT/CSV
HTML/XML
XML/JSON
CSV/JSON
Which CSS selector will target only the last list item?
ul:nth-child(last) {}
ul:last-child {}
ul li:last-child {}
ul:last-child(li) {}
What key feature of Node.js is crucial for building REST APIs?
Access to the DOM
Managing HTTP requests and server-side functionality
Handling client-side events
File management
Inline elements are normally displayed without starting a new line.
True
False
What is the correct HTML for inserting an image?
image.gif

In HTML, which attribute is used to specify that an input field must be filled out?
placeholder
validate
formvalidate
required
Which HTML tag is used to define an internal style sheet?
What is the correct HTML for creating a hyperlink?
What is the correct HTML for making a text input field?
Which type of CSS is coded in the body of the web page as an attribute of an HTML tag?
inline
embedded
external
imported
How do you select an element with id "demo"?
.demo
:demo
#demo
demo
Which CSS property is used to change the text color of an element?
foreground-color
text-color
color
font-color
How can you created rounded corners using CSS3?
border-radius: 8px;
border [round]: 8px;
corner-effect: round;
alpha-effect: round-corner;
Which of the following is not a property of Flex box?
align-items
justify-spacing
justify-content
flex-direction
How do you call a function named myFunction?
call function myFunction()
call myFunction()
myFunction()
myFunction.run()
Which of the following will assign the value 5 to the variable productCost?
productCost <= 5;
productCost = 5;
productCost == 5;
productCost <= 5;
What is the correct way to write a JavaScript array?
let colors = "red", "green", "blue"
let colors = 1 = ("red"), 2 = ("green"), 3 = ("blue")
let colors = ["red", "green", "blue"]
let colors = {1:"red",2:"green",3:"blue"}
Inside which HTML element do we put the JavaScript?
Which method of the window object can be used to display a message to the user?
alert()
display()
message()
status()
When the user moves the mouse pointer away from a link it had been hovering over, the browser detects which one of these events?
mouseup
mouseaway
mouseoff
mouseout
What is the function to stop an interval timer?
stopTimer
clearInterval
clearTimer
shutdown Timer
What is the output of the code below? function job() { return new Promise(function (resolve, reject) { reject(); }); } job().then(function() { console.log('Success 1'); }) .then(function() { console.log('Success 2'); }) .catch(function() { console.log('Error'); })
What is the default HTTP method used by the fetch function?
GET
Request
FormData
POST
Which of the following best describes x? let x = await fetch(URL);
A Promise object
An object parsed from JSON
The response text
An object which contains the meta data of the response
What is Node.js?
A Java-based framework
A network application framework
A web server
A JavaScript-based framework
How do you install global packages with npm?
npm install -1
npm global
npm install -g
npm install -global
Node.js runs on?
Client
Server
Both Client and Server
Browser
What is callback?
A function that is passed as an argument to another function.
A backend endpoint's URL.
An API call to the backend.
An asynchronous equivalent for a function.
Which of these is not a core feature of Express?
Templating
Routing
ORM
Middleware
Where can you access the capture values of URL parameters?
From the req.query object
From the req.params object
From the req.data object
From the req.body object
To serve static files like images, CSS files, and JavaScript files in Express, you use:
res.sendFile()
express.static()
res.sendStatic()
app.static()
Which middleware in Express.js helps in handling JSON data from POST requests?
(a)
How do you retrieve the value of a specific cookie sent in a request in Express.js?
req.cookie.value
req.values.cookieName
req.get('cookieName')
req.cookies[cookieName]
In Express, if you want a middleware function to be executed for every request, where would you place it?
Inside each route definition
Inside the app's main file
Before all route definitions
At the end of all route definitions
What is the method that allows you to write content to a file?
fs.write
fs.output
fs.writeFile
fs.writeOut
Which of the following Node modules is required for working with files and directories on the server?
os
fs
files
system
Which of the following is not a valid HTTP method?
HEADER
PUT
GET
POST
JSX stands for?
JavaScript executable
JavaScript XML
JointScript XML
JavaScreenXML
React separates the user interface into components. How are components combined to create a user interface?
By putting them in a folder structure
By nesting components
With webpack
With code splitting
What is a hook in React?
A hook helps you use state and lifecycle methods behavior in functional components
A hook helps you customize a component
A hook lets you hook up components to events
A hook helps you create component's lifecycle
What is the <>> tag called in React?
Grouper
Empty
React can only render elements in the root document element.
True
False
Choose the best HTML element to define italic text
How we call a data record in MongoDB?
Collection
Document
Row
Table
Which of these lines of code works in NodeJS?
const button = document.querySelector("button");
console.log("VS");
const name VB;
None of these
Which of the following command can be used in mongo shell to show all the collections in your selected MongoDB database?
show db –all
show collections
show databases
show dbs
Which of these is correct to define an array in JavaScript?
int[] list = new int[]{1,2,3};
let list = [1,2,3];
const list = (1,2,3);
int[] list = new Array(1,2,3);
What is the correct JavaScript syntax to change the content of the Hello World below?
This is a demonstration.
document.querySelector("#demo").innerHTML = "Hello World!";
document.querySelectorAll(".demo").textContent = "Hello World!";
document.querySelectorAll("#demo").textContent = "Hello World!";
document.querySelector(".demo").innerHTML = "Hello World!";
In ReactJS, state can be used to pass
Event handler to component
None of these
Both of these
Properties to the component
Which of these is correct about HTML block elements?
Small amount of content, no height or width
Small amount of content, has height and width
Take up the full width of the page (flows top to bottom)
Large blocks of content, has height and width
Which of the following statements executes the code of abc.js?
node abc.js
None of these
abc.js
nodejs abc
Which of these is a valid built-in event in JavaScript?
onSubmit
click
onClick
onChange
As soon as the props of a React component are changed, the component will:
do nothing, you must call render method to render the component
be created again from scratch
re-render the component
None of these
Which of the following is a template engine for Node js?
Mongoose
Handlebars
None of these
ReactJS
React Lifecycle method componentDidMount() is called when
Component is rendered for the first time
Both of these
State of the component is updated
None of these
The variables, functions in Nodejs modules can be exposed using
module
module.expose
module.exports
All of them
Which npm library is used to read and write to the MongoDB database from NodeJS?
mongod
mongodb
MongoClient
mongo
In React component life cycle, which functions below is the best position to fetch data from API?
constructor
getDerivedStateFromProps
componentDidMount
render
Which of these is NOT a preferred way to communicate between the two classes App and Present in the design App → Has a list of Presents → Present
Present dispatches custom events in response to actions. App listens for these events, then calls its corresponding methods
Give Present a reference to App in its constructor. Present can use this reference to call methods from App
App can just call methods on Present since App has a list of the Present objects
App passes one or more of its methods to Present as parameters. Present calls them in response to corresponding actions.
Which of these is NOT suggested to support a responsive website?
Use media queries to add styles for devices with different screen width
Always add the meta viewport tag
For fonts, prefer px
For height and width, prefer percentages
