Font size
WorksheetsHTML, CSS, JavaScript, and React Quiz
Total questions: 61
Worksheet time: 30mins
Which attribute is used to provide a unique identifier to an HTML element?
class
id
name
tag
What does the tag in HTML stand for?
Anchor
Alignment
Article
Attribute
Which property is used to change the background color of an element?
color
bgcolor
background-color
background
How do you make text bold in CSS?
font-bold: true;
font-weight: bold;
text-style: bold;
text-weight: bold;
Which CSS property is used to control the spacing between lines of text?
spacing
line-height
text-indent
margin-top
Which CSS property controls the stacking order of elements?
z-index
position
order
stack
How do you declare a JavaScript variable?
var x;
dim x;
declare x;
int x;
What is the output of console.log(typeof null)?
null
object
undefined
string
Which method is used to parse a string to an integer in JavaScript?
parseString()
parseInt()
toInteger()
int()
How can you add a comment in JavaScript?
// This is a comment
/* This is a comment */
# This is a comment
What does NaN mean in JavaScript?
Not-a-Number
No-a-Number
Null-a-Number
None-a-Number
What is JSX?
A syntax extension for JavaScript
A library for building APIs
A CSS framework
A database query language
Which method is used to create a React component?
React.createComponent()
React.createClass()
React.Component
React.makeComponent()
Which lifecycle method is invoked immediately after a component is updated?
componentDidMount
componentDidUpdate
componentWillUpdate
shouldComponentUpdate
Which hook is used to manage state in a functional component?
useState
useEffect
useReducer
useContext
How do you pass data from a parent to a child component in React?
With hooks
Using state
Through props
Via context
Which of the following is true about Node.js?
It is a client-side framework
It is a backend runtime environment
It is used for designing UIs
It is a package manager
Which module is used for handling file operations in Node.js?
http
file
fs
os
Which command is used to initialize a Node.js project?
npm start
npm install
npm init
node create
What does require() do in Node.js?
Imports modules
Exports modules
Starts a server
Runs the application
What is the default file name used by Node.js when serving a project?
index.html
index.js
main.js
app.js
What is Bootstrap?
A CSS framework
A JavaScript library
A database
An image editor
Which class in Bootstrap creates a responsive navigation bar?
nav-bar
navbar
navbar-responsive
navbar-expand-lg
Which Bootstrap class is used to add rounded corners to an image?
img-border
img-rounded
rounded
border-img
Which class adds a primary button in Bootstrap?
btn-main
btn-primary
btn-default
btn-main-primary
What is the purpose of the tag in HTML?
To define meta-information about the web page
To create hyperlinks
To insert multimedia files
To define a navigation bar
Which attribute is used to specify the URL for a hyperlink?
src
href
url
link
Which property is used to change the font of an element?
font-style
font-family
font-weight
text-font
What does the 'position: absolute;' CSS property do?
Positions the element relative to the viewport
Positions the element relative to its nearest positioned ancestor
Positions the element relative to its parent
Positions the element at a fixed point on the page
Which CSS pseudo-class is used to style an element when the user hovers over it?
:hover
:focus
:active
:visited
How do you apply a CSS rule to an element with the ID 'main'?
.main { ... }
#main { ... }
main { ... }
*main { ... }
Which property is used to add space inside the border of an element?
margin
padding
border-spacing
space
What does Array.prototype.map() do in JavaScript?
Modifies the original array
Creates a new array by applying a function to each element
Sorts the array
Combines two arrays
What is the correct syntax to write a function in JavaScript?
function myFunction() { ... }
def myFunction() { ... }
function: myFunction() { ... }
myFunction() => { ... }
What will console.log('10' - 2) output?
102
NaN
8
TypeError
Which of the following is not a valid JavaScript data type?
Number
Boolean
Float
Object
How do you access the third element in the array let arr = [10, 20, 30, 40];?
arr(2)
arr[2]
arr[3]
arr.get(2)
Which React method is used to update the state of a component?
this.setState()
this.updateState()
this.changeState()
this.modifyState()
What is useEffect used for in React?
To fetch data only
To perform side effects in a functional component
To manage state in a component
To define event handlers
Which of the following is a valid way to render a list in React?
{items.map(item => {item.name})}
{items.map(item => {item.name})}
{items.foreach(item => {item.name})}
{items.forEach(item => {item.name})}
What is the virtual DOM in React?
A lightweight copy of the real DOM
A replacement for the real DOM
A type of browser cache
A debugging tool
Which of the following is used to manage global state in React?
useContext
Redux
Both a and b
None of the above
Which of the below options is correct to change the background color to blue in CSS?
body {
background-colour: lightblue;
}
body {
background-color: lightblue;
}
body {
background:color: lightblue;
}
None of the above
Predict the output for the piece of code:
<html>
<body>
<script language="JavaScript">
function Test(){
document.write("Hello World!");
}
</script>
<input type="submit" value="click here" onclick="Test()"/>
</body>
</html>
Error
Displays Hello World! Along with clickhere button
Displays Hello World! after clicking on clickhere button
Displays nothing
Predict the output:
<p id="test"></p>
<script>
var date = 10;
month = "July";
var year = 2020;
document.getElementById("test").innerHTML =
date + "<br>" + month + "<br>" + year
</script>
No output
44022
10
July
2020
10
2020
Predict the output:
<!DOCTYPE html>
<html>
<body>
<p id="test"></p>
<script>
function firstFunction(p1, p2) {
return p1 + p2;
}
document.getElementById("test").innerHTML = firstFunction(1, 5);
</script>
</body>
</html>
6
No output
Error while declaring the function
None of the above
What is the default file extension for JavaScript files?
.html
.css
.js
.java
Which of the following is a JavaScript framework?
Laravel
Django
React
Flask
Change the border size of the body or image
border-style
border-width
border-color
width
Which rule set would change the font size to 24?
font-size: 24
size: 24;
font-size: 24;
font size: 24;
What is missing from this HTML skeleton?
<!DOCTYPE html>
<html>
<body>
</body>
</html>
<head></head>
<div></div>
<img></img>
<head>
