WBT MCQ Bank
WBT MCQ Bank
WBT MCQ Bank
Answer: b) 1970s
Answer: a) ARPANET
What year was the World Wide Web (WWW) proposed by Tim Berners-Lee?
a) 1989
b) 1991
c) 1993
d) 1995
Answer: b) 1991
Which organization played a crucial role in the development and standardization of the Internet
protocols?
a) IEEE
b) IETF
c) ISO
d) ICANN
What technology enables devices to connect and communicate with each other over the Internet?
a) HTTP
b) TCP/IP
c) DNS
d) HTML
Which device is responsible for directing data packets to their destination across networks?
a) Router
b) Modem
c) Hub
d) Switch
Answer: a) Router
Which communication model allows multiple users to access a single server simultaneously without
interfering with each other's sessions?
a) Client-Server model
b) Peer-to-Peer model
c) Broadcast model
d) Multicast model
Which network component provides physical connections between devices within a local network?
a) Router
b) Switch
c) Modem
d) Hub
Answer: b) Switch
HTTP uses a request-response model, where a client sends a request to the server using a specific
HTTP method. Which method is used to request data from a server?
a) POST
b) PUT
c) GET
d) DELETE
Answer: c) GET
When you type a domain name in your browser, what does the DNS server do?
a) It downloads the website's content to your computer.
b) It translates the domain name into an IP address.
c) It checks if the domain name is available for registration.
d) It establishes a secure connection with the website.
Which organization oversees the allocation and management of domain names and IP addresses?
a) IETF
b) W3C
c) ICANN
d) IEEE
Answer: b) POST
Answer: c) OK
Which HTTP status code indicates that the resource is temporarily unavailable, and the client should
try again later?
a) 201 Created
b) 302 Found
c) 503 Service Unavailable
d) 404 Not Found
Topic: Difference between HTTP 1.0, HTTP 1.1, and HTTP 2.0
How does HTTP 1.1 differ from HTTP 1.0 regarding connection management?
a) HTTP 1.0 uses persistent connections, while HTTP 1.1 uses non-persistent connections.
b) HTTP 1.0 uses non-persistent connections, while HTTP 1.1 uses persistent connections.
c) Both HTTP 1.0 and HTTP 1.1 use persistent connections.
d) Both HTTP 1.0 and HTTP 1.1 use non-persistent connections.
Answer: b) HTTP 1.0 uses non-persistent connections, while HTTP 1.1 uses persistent connections.
What is the key improvement introduced in HTTP 1.1 compared to HTTP 1.0?
a) Introduction of the POST method
b) Support for cookies
c) Addition of status codes
d) Use of persistent connections
Which version of HTTP introduced server push functionality to enhance web performance?
a) HTTP 1.0
b) HTTP 1.1
c) HTTP 2.0
d) HTTP 3.0
What is the main advantage of using HTTP 2.0 over HTTP 1.1?
a) Improved security features
b) Faster page loading through multiplexing and compression
c) Support for advanced scripting languages
d) Compatibility with older web browsers
Which version of HTTP is still in use but considered outdated due to its limitations in performance and
security?
a) HTTP 1.0
b) HTTP 1.1
c) HTTP 2.0
d) HTTP 3.0
Which HTTP method is used to retrieve data from a server without modifying it?
a) GET
b) POST
c) PUT
d) DELETE
Answer: a) GET
When using the GET method, where does the data reside in the HTTP request?
a) In the request body
b) In the request headers
c) In the URL query parameters
d) In the response body
Answer: c) PUT
Answer: c) OK
Which HTTP status code is returned when a resource has been successfully created on the server?
a) 201 Created
b) 204 No Content
c) 400 Bad Request
d) 403 Forbidden
Answer: c) Forbidden
Answer: b) The client maintains state information, and the server is stateless.
To maintain session state in HTTP, what mechanism can be used to store session information between
requests?
a) Cookies
b) HTTP headers
c) URL query parameters
d) Web sockets
Answer: a) Cookies
In a stateless HTTP session, where is the session information stored between consecutive requests from
the same client?
a) On the server's local file system
b) In a server-side database
c) In the client's browser as cookies
d) In the URL query parameters
What happens if the client loses the session information (e.g., due to clearing cookies)?
a) The server sends a 404 status code to the client.
b) The server generates a new session ID for the client.
c) The server retrieves the session information from a backup database.
d) The client needs to re-authenticate and start a new session.
Topic: HTTPS
Answer: b) 443
Which certificate authority (CA) is responsible for issuing SSL/TLS certificates to websites?
a) IETF
b) W3C
c) ICANN
d) Let's Encrypt
Answer: b) Clients sending requests to servers, which then send back the requested data.
The web browser displays the content of a web page using which language?
a) XML
b) JavaScript
c) HTML
d) CSS
Which web server is open-source and widely used across various operating systems?
a) IIS (Internet Information Services)
b) Apache server
c) Nginx
d) Tomcat
The Apache server is commonly used to serve which type of web content?
a) Dynamic web pages
b) Streaming video content
c) Static web pages
d) Database queries
IIS (Internet Information Services) is typically used in conjunction with which operating system?
a) macOS
b) Linux
c) Windows
d) Android
Answer: c) Windows
Which browser introduced support for HTML5 and promoted its adoption?
a) Internet Explorer
b) Mozilla Firefox
c) Google Chrome
d) Safari
Answer: c) <a>
Answer: a) An image
Answer: c) <ul>
What is the purpose of the <iframe> tag in HTML?
a) To create a hyperlink
b) To embed external content in a web page
c) To define a table
d) To format text
Topic: HTML5
Answer: b) HTML5
HTML5 introduces a semantic approach to web page structure. What does "semantic" mean in this
context?
a) The use of abstract elements without specific meanings
b) The use of elements based on their presentational styles
c) The use of elements with specific meanings and roles
d) The use of elements with complex structures
Which HTML5 element is used to define a section that can be reused throughout the document?
a) <section>
b) <div>
c) <article>
d) <header>
Answer: b) <div>
HTML5 introduced a new way of storing data on the client-side. What is this feature called?
a) Local storage
b) Session storage
c) Cache storage
d) Database storage
Which attribute is used to specify the source of an audio file in the <audio> tag?
a) src
b) href
c) link
d) location
Answer: a) src
Answer: c) To ensure that the web page complies with HTML5 syntax and rules
In HTML5, which attribute is used to specify the character encoding of the document and aid in
validation?
a) charset
b) encoding
c) type
d) lang
Answer: a) charset
Answer: a) MP3
Answer: a) Using the <video> tag with the video file's URL in the src attribute
What attribute is used in the <video> tag to specify whether the video should start playing
automatically?
a) autoplay
b) play
c) start
d) auto-play
Answer: a) autoplay
Which attribute is used to specify a fallback audio file for browsers that do not support the <audio> tag
or the specified audio format?
a) fallback
b) alternative
c) alt
d) backup
Answer: a) fallback
How can you control the volume of an audio or video element using HTML5?
a) There is no volume control in HTML5; it must be controlled by external scripts.
b) Using the volume attribute with values between 0.0 (silent) and 1.0 (full volume)
c) By adding volume control buttons next to the audio or video element
d) By specifying the volume in the CSS style of the <audio> or <video> tag
Answer: b) Using the volume attribute with values between 0.0 (silent) and 1.0 (full volume)
What is the method used to retrieve the user's current location using the Geolocation API in HTML5?
a) getUserLocation()
b) getCurrentPosition()
c) findUserLocation()
d) getCurrentLocation()
Answer: b) getCurrentPosition()
The Geolocation API requires user permission to access the user's location. How does the browser
prompt the user for permission?
a) By automatically allowing access without prompting the user
b) By displaying a message requesting permission to access location information
c) By displaying a map showing the user's current location and asking for confirmation
d) By redirecting the user to the device's location settings
What information does the Geolocation API provide about the user's location?
a) The user's name and contact information
b) The latitude and longitude coordinates of the user's current position
c) The user's home address and zip code
d) The user's IP address and internet service provider
Answer: b) The latitude and longitude coordinates of the user's current position
Answer: b) No, it is only supported on mobile devices and some modern browsers.
Answer: a) <form>
The <input> tag is used to create various form controls. Which type attribute is used to create a
checkbox?
a) type="checkbox"
b) type="check"
c) type="radio"
d) type="option"
Answer: a) type="checkbox"
Which form control allows users to select multiple options from a list?
a) <select>
b) <radio>
c) <checkbox>
d) <input type="range">
Answer: a) <select>
The <button> tag in HTML is used to create a clickable button. What is the default behavior of a button
element in a form?
a) It submits the form data to the server.
b) It resets the form to its initial values.
c) It opens a new web page specified in the form's action attribute.
d) It does not have any default behavior; it needs JavaScript to handle its functionality.
Answer: d) It does not have any default behavior; it needs JavaScript to handle its functionality.
Answer: c) It is an application programming interface (API) that represents the structure of an HTML
document as objects.
Answer: c) By querying and manipulating the HTML elements and attributes using JavaScript
Answer: d) getElementById
The DOM allows you to add event listeners to HTML elements. What are event listeners used for?
a) To modify the appearance of HTML elements
b) To add new HTML elements to a web page
c) To handle user interactions with HTML elements, such as clicks or input
d) To query and manipulate the document's structure
Answer: c) To handle user interactions with HTML elements, such as clicks or input
Answer: c) <p>
Answer: b) It refers to the way styles are applied from top to bottom in an HTML document.
Answer: c) color
Which CSS property is used to control the spacing between lines of text?
a) line-height
b) letter-spacing
c) word-spacing
d) text-indent
Answer: a) line-height
How can you apply multiple CSS styles to a single HTML element?
a) By using the <styles> tag
b) By linking multiple CSS files in the HTML document
c) By using multiple <style> tags in the HTML document
d) By separating the styles with commas within the <style> tags
Answer: a) border-radius
What is the correct CSS syntax to apply a background color to a paragraph element with the class
"highlight"?
a) .highlight { background-color: #FF0000; }
b) #highlight { background-color: #FF0000; }
c) <p class="highlight"> { background-color: #FF0000; }
d) <paragraph class="highlight"> { background-color: #FF0000; }
How can you apply CSS styles to a specific HTML element with the ID "header"?
a) .header { /* CSS styles here / }
b) #header { / CSS styles here / }
c) <header> { / CSS styles here / }
d) <div id="header"> { / CSS styles here */ }
How can you apply CSS styles to multiple HTML elements with the class "highlight"?
a) .highlight { /* CSS styles here / }
b) #highlight { / CSS styles here / }
c) <p class="highlight"> { / CSS styles here / }
d) <div class="highlight"> { / CSS styles here */ }
How can you apply a CSS style to all <h2> elements within a <div> element?
a) div h2 { /* CSS styles here / }
b) div > h2 { / CSS styles here / }
c) div + h2 { / CSS styles here / }
d) div ~ h2 { / CSS styles here */ }
Answer: b) The spacing between the content and the border of an element
How can you apply CSS styles to all <a> elements that are children of a <div> element with the class
"menu"?
a) .menu <a> { /* CSS styles here / }
b) #menu <a> { / CSS styles here / }
c) div.menu <a> { / CSS styles here / }
d) <div class="menu"> <a> { / CSS styles here */ }
How can you apply a CSS style to an element only when the mouse pointer is hovering over it?
a) :hover { /* CSS styles here / }
b) :active { / CSS styles here / }
c) :focus { / CSS styles here / }
d) :link { / CSS styles here */ }
How can you apply a CSS style to the first line of text within an element?
a) :first-line { /* CSS styles here / }
b) :first-child { / CSS styles here / }
c) :first-letter { / CSS styles here / }
d) :first-of-type { / CSS styles here */ }
How can you apply a CSS style to an element only when it is visited by the user?
a) :visited { /* CSS styles here / }
b) :active { / CSS styles here / }
c) :hover { / CSS styles here / }
d) :link { / CSS styles here */ }
Answer: a) Define the position of an element in the z-axis (depth) of the page
How can you apply a CSS style to an element only when the user is interacting with it?
a) :focus { /* CSS styles here / }
b) :active { / CSS styles here / }
c) :hover { / CSS styles here / }
d) :link { / CSS styles here */ }
How can you apply a CSS style to an element only when it is the last child of its parent element?
a) :last-child { /* CSS styles here / }
b) :last-of-type { / CSS styles here / }
c) :last-line { / CSS styles here / }
d) :last-letter { / CSS styles here */ }
Answer: b) CSS written directly within the HTML element's "style" attribute
Answer: a) CSS written within the <head> section of the HTML document
Which method of applying CSS is considered the best practice for larger websites with multiple pages?
a) Inline CSS
b) Internal CSS
c) External CSS
d) Applying CSS using JavaScript
Answer: b) It ensures that CSS styles are applied consistently across multiple pages
Which CSS type has the highest specificity and will override other CSS rules?
a) Inline CSS
b) Internal CSS
c) External CSS
d) All CSS types have equal specificity
What is the correct way to link an external CSS file to an HTML document?
a) <link href="styles.css" type="text/css" rel="stylesheet">
b) <css src="styles.css"></css>
c) <style src="styles.css"></style>
d) <css file="styles.css"></css>
Can you use multiple external CSS files on a single HTML document?
a) Yes, but it may cause conflicts between the styles.
b) No, only one external CSS file can be linked to an HTML document.
c) Yes, but they must be merged into a single CSS file before linking.
d) Yes, by using the <style> tag to embed them in the <head> section.
What happens if the same CSS property is defined in both an external CSS file and inline CSS for the
same HTML element?
a) The inline CSS will take precedence over the external CSS.
b) The external CSS will take precedence over the inline CSS.
c) Both styles will be combined and applied to the element.
d) The browser will display an error.
Answer: a) The inline CSS will take precedence over the external CSS.
How does the use of External CSS improve website maintenance and management?
a) It allows for faster loading of the web page.
b) It reduces the need to update styles across multiple pages.
c) It eliminates the need for the <style> tag in the HTML document.
d) It automatically generates CSS styles based on the HTML structure.
When using multiple styles for the same HTML element, which style takes precedence?
a) The style defined in the first linked CSS file
b) The style defined in the last linked CSS file
c) The style defined in the inline CSS
d) The style defined in the <head> section of the HTML document
How can you apply different font styles to different HTML elements using CSS?
a) By using the <font> tag with different font styles for each element
b) By defining font styles in the <head> section of the HTML document
c) By linking multiple CSS files with different font styles for each element
d) By using the "font" property in the CSS style for each element
Answer: d) By using the "font" property in the CSS style for each element
Which CSS property is used to set the size of the text font?
a) font-size
b) font-family
c) font-weight
d) font-style
Answer: a) font-size
What is the correct way to define a font stack in CSS, where "Arial" is the preferred font and "sans-
serif" is the fallback?
a) font-family: Arial, sans-serif;
b) font-family: sans-serif, Arial;
c) font-family: Arial;
d) font-family: sans-serif;
How can you apply a CSS style to all <h1> elements on a web page?
a) h1 { /* CSS styles here / }
b) .h1 { / CSS styles here / }
c) <h1> { / CSS styles here / }
d) #h1 { / CSS styles here */ }
How can you apply a CSS style to an element only when it is the first child of its parent element?
a) :first-child { /* CSS styles here / }
b) :first-of-type { / CSS styles here / }
c) :first-line { / CSS styles here / }
d) :first-letter { / CSS styles here */ }
How many layers or components are included in the CSS Box Model?
a) 2
b) 3
c) 4
d) 5
Answer: c) 4
Answer: d) Background
Answer: a) The space between the content and the border of an element
Answer: d) How the total width and height of an element are calculated
Answer: a) content-box
How can you include the padding and border in the total width and height of an element's box?
a) box-sizing: border-box;
b) box-sizing: content-box;
c) box-sizing: padding-box;
d) box-sizing: margin-box;
What is the formula for calculating the total width of an element's box, including content, padding, and
border?
a) total width = width + padding + border
b) total width = width + padding * 2 + border * 2
c) total width = width - padding - border
d) total width = width - padding * 2 - border * 2
Answer: b) #id
Answer: a) .class
Answer: c) Yes, an element can have both "id" and "class" attributes at the same time.
How is the "id" attribute different from the "class" attribute in HTML?
a) The "id" attribute is used to group elements, while the "class" attribute is used to identify unique
elements.
b) The "id" attribute can only be used once per page, while the "class" attribute can be used multiple
times.
c) The "id" attribute is represented by a period (.), while the "class" attribute is represented by a pound
(#) symbol.
d) The "id" attribute is only used for styling, while the "class" attribute is used for JavaScript functions.
Answer: b) The "id" attribute can only be used once per page, while the "class" attribute can be used
multiple times.
How can you select an element with the "id" attribute of "header" in CSS?
a) .header { /* CSS styles here / }
b) #header { / CSS styles here / }
c) <header> { / CSS styles here / }
d) <div id="header"> { / CSS styles here */ }
How can you select all elements with the "class" attribute of "highlight" in CSS?
a) .highlight { /* CSS styles here / }
b) #highlight { / CSS styles here / }
c) <highlight> { / CSS styles here / }
d) <div class="highlight"> { / CSS styles here */ }
What is the main purpose of using the "id" and "class" attributes in HTML and CSS?
a) To apply unique styles to specific elements (id) and group similar elements together (class)
b) To create interactive elements on the web page
c) To define the box model of elements
d) To add background colors to the page
Answer: a) To apply unique styles to specific elements (id) and group similar elements together (class)
In CSS, if a style is applied to both an element's "id" and "class," which one takes precedence?
a) The "id" takes precedence over the "class."
b) The "class" takes precedence over the "id."
c) Both styles are applied.
d) The style defined last takes precedence.
How can you use the <style> tag to apply CSS styles to a specific HTML element?
a) <style> .element { /* CSS styles here / } </style>
b) <style> #element { / CSS styles here / } </style>
c) <style> <element> { / CSS styles here / } </style>
d) <style> <.element> { / CSS styles here */ } </style>
How does using the <style> tag differ from using an external CSS file?
a) The <style> tag allows for more advanced CSS features.
b) The <style> tag is used for internal CSS, while external CSS files are linked to the HTML document.
c) The <style> tag is faster and improves web page loading times.
d) Using the <style> tag is considered bad practice.
Answer: b) The <style> tag is used for internal CSS, while external CSS files are linked to the HTML
document.
What is the main disadvantage of using the <style> tag for CSS styles?
a) It increases the file size of the HTML document.
b) It makes the CSS code harder to manage and maintain.
c) It can cause conflicts with external CSS styles.
d) It cannot be used to style multiple HTML documents at once.
How can you apply CSS styles to multiple HTML elements using the <style> tag?
a) By adding a separate <style> tag for each element
b) By using multiple <style> tags within the <head> section
c) By separating the styles with commas inside the <style> tag
d) By using the "class" attribute with the <style> tag
Answer: c) By separating the styles with commas inside the <style> tag
What is the correct syntax to define a CSS rule for all <p> elements inside a <div> element using the
<style> tag?
a) div p { /* CSS styles here / }
b) div > p { / CSS styles here / }
c) div + p { / CSS styles here / }
d) div ~ p { / CSS styles here */ }
What happens if the same CSS rule is defined multiple times inside the <style> tag?
a) The browser ignores all but the last instance of the rule.
b) The browser averages the values of the rules.
c) The browser combines all the rules into one.
d) The browser displays an error.
Answer: a) The browser ignores all but the last instance of the rule.
How can you apply CSS styles to all <a> elements that are children of a <div> element using the <style>
tag?
a) div a { /* CSS styles here / }
b) div > a { / CSS styles here / }
c) div + a { / CSS styles here / }
d) div ~ a { / CSS styles here */ }
When using the <style> tag, how can you comment out a block of CSS code?
a) /* This is a comment */
b) // This is a comment //
c) <!-- This is a comment -->
d) # This is a comment #
Answer: c) styles.css
What is the correct syntax to link an external CSS file to an HTML document?
a) <link href="styles.css" type="text/css" rel="stylesheet">
b) <css src="styles.css"></css>
c) <style src="styles.css"></style>
d) <css file="styles.css"></css>
Where is the <link> tag for the external CSS file typically placed in an HTML document?
a) Before the <head> tag
b) After the <head> tag and before the <body> tag
c) After the <body> tag
d) Inside the <head> tag
Answer: c) Yes, an HTML document can link to multiple external CSS files.
How do you create a link to an external CSS file located in the "css" folder within the root directory of
the website?
a) <link href="css/styles.css" type="text/css" rel="stylesheet">
b) <link href="styles.css" type="text/css" rel="stylesheet">
c) <link href="../css/styles.css" type="text/css" rel="stylesheet">
d) <link href="css/styles" type="text/css" rel="stylesheet">
What happens if the <link> tag for the external CSS file is placed after the <body> tag?
a) The CSS styles will not be applied to the HTML document.
b) The browser will display an error.
c) The CSS styles will be applied, but it is not considered good practice.
d) The CSS styles will be applied, but only to specific elements.
Answer: a) The CSS styles will not be applied to the HTML document.
How can you create a link to an external CSS file that is optimized for printing?
a) <link href="print.css" type="text/css" rel="print">
b) <link href="styles.css" type="text/css" rel="print">
c) <link href="print.css" type="text/css" rel="stylesheet">
d) <link href="styles.css" type="text/css" rel="stylesheet" media="print">
Answer: d) It allows the CSS file to be cached, reducing loading times for subsequent pages.
Answer: d) Netscape
Answer: d) Character
Answer: c) const
Answer: d) &
Which type of scope allows a variable to be accessed from anywhere in the code?
a) Local scope
b) Block scope
c) Global scope
d) Function scope
What happens if you declare a variable with the same name inside a block with "let" that already exists
in the outer scope?
a) The variable in the outer scope is overwritten by the inner variable.
b) An error is thrown, and the code stops executing.
c) Both variables can be used independently without any conflicts.
d) The variable in the outer scope becomes inaccessible.
Answer: a) The variable in the outer scope is overwritten by the inner variable.
Answer: c) string.length
Answer: b) toUpperCase()
Answer: a) number
Answer: c) 42
Which of the following is NOT a valid number in JavaScript?
a) 3.14
b) 0
c) -123
d) "42"
Answer: d) "42"
Answer: b) Math.round(number)
Which comparison operator is used to check if two values are equal in JavaScript?
a) ==
b) =
c) ===
d) <>
Answer: a) ==
Answer: a) true
How can you negate a boolean value in JavaScript?
a) !value
b) not(value)
c) (value)
d) not value
Answer: a) !value
Answer: b) date.setFullYear(2023);
Answer: c) To convert a date to a string in the format "Day, Month DD, YYYY"
Answer: a) [1, 2, 3]
How can you access the value at index 2 in an array named "myArray"?
a) myArray.get(2)
b) myArray[2]
c) myArray.at(2)
d) myArray.value(2)
Answer: b) myArray[2]
Answer: c) myArray.length
How do you access the value of a property named "name" in an object named "person"?
a) person.getName()
b) person[name]
c) person.name()
d) person.name
Answer: d) person.name
How can you add a new method named "sayHello" to an existing object named "user"?
a) user.sayHello() { /* code here / }
b) user.sayHello = function() { / code here / }
c) user = function() { / code here / }
d) sayHello(user) { / code here */ }
Answer: d) A block of code that can be invoked and perform a specific task
Answer: c) myFunction()
Answer: b) A function that belongs to an object and can be invoked to perform specific actions
Answer: b) Keeping the implementation details of an object hidden and only exposing the necessary
interfaces
Answer: a) <html>
Answer: a) getElementById()
Answer: b) Objects
How can you access the first <p> element in the DOM using JavaScript?
a) document.getElementsByTagName("p")[0]
b) document.querySelector("p")
c) document.getElementById("p")
d) document.firstElement("p")
Answer: b) document.querySelector("p")
Which DOM property is used to change the text content of an HTML element?
a) innerText
b) innerHTML
c) textContent
d) contentText
Answer: c) textContent
How can you add an event listener to a button element with the ID "myButton" that executes a function
called "handleClick" when the button is clicked?
a) document.getElementById("myButton").addEventListener("click", handleClick)
b) document.querySelector("myButton").onclick = handleClick
c) myButton.addEventListener("click", handleClick)
d) document.addEventListener("myButton", "click", handleClick)
How can you insert a new element as the last child of a parent element in the DOM?
a) parentElement.insertBefore(newElement, parentElement.firstChild)
b) parentElement.insertBefore(newElement, parentElement.lastChild)
c) parentElement.appendChild(newElement)
d) parentElement.insertAfter(newElement, parentElement.lastChild)
Answer: c) parentElement.appendChild(newElement)
Answer: b) removeChild()
How do you change the text content of an HTML element with the ID "myElement" to "Hello, World!"?
a) document.getElementById("myElement").textContent = "Hello, World!";
b) document.getElementByName("myElement").innerText = "Hello, World!";
c) document.querySelector("#myElement").textContent = "Hello, World!";
d) document.getElementById("myElement").innerText = "Hello, World!";
How can you access the value entered in a text input element with the ID "username" using JavaScript?
a) document.getElementByTagName("username").value
b) document.getElementById("username").value
c) document.getElementByClassName("username").value
d) document.querySelector("#username").value
Answer: b) document.getElementById("username").value
Answer: b) Checking if a form has been filled out correctly before submission
How can you prevent a form from being submitted if it does not pass validation?
a) Using the "preventDefault()" method in the form's submit event listener
b) Setting the "onSubmit" attribute of the form to a validation function
c) Disabling the submit button until the form is valid
d) Removing the "action" attribute from the <form> tag
Answer: a) Using the "preventDefault()" method in the form's submit event listener
Which HTML attribute is used to specify the type of input for a text field that only allows numbers?
a) type="text"
b) type="number"
c) type="integer"
d) type="numeric"
Answer: b) type="number"
Answer: c) test()
What does the "i" flag in a regular expression do?
a) Specifies a global search
b) Specifies a case-sensitive search
c) Specifies a multiline search
d) Specifies a case-insensitive search
Which regular expression pattern is used to match any digit character in JavaScript?
a) /\d/
b) /\w/
c) /\s/
d) /\D/
Answer: a) /\d/
How can you replace all occurrences of the word "apple" with "orange" in a string using regular
expressions?
a) string.replace("apple", "orange")
b) string.replaceAll("apple", "orange")
c) string.replace(/apple/g, "orange")
d) string.replace(/apple/i, "orange")
Which method is used to display messages in the browser's developer console for debugging purposes?
a) alert()
b) confirm()
c) console.log()
d) document.write()
Answer: c) console.log()
Answer: b) To execute code inside the "try" block and handle errors in the "catch" block
Answer: c) throw()
How can you check the type of an error object in a "catch" block?
a) error.type
b) error.message
c) error.name
d) error.value
Answer: c) error.name
Topic: Introduction to Browser Dev Tool, Pushing Code Quality via JSLint Tool
Browser Developer Tools provide features like:
a) Checking email accounts
b) Making phone calls
c) Debugging JavaScript code
d) Creating HTML documents
Which key is typically used to open the Browser Developer Tools in most web browsers?
a) F5
b) F12
c) Ctrl + Shift + D
d) Alt + Enter
Answer: b) F12
Answer: d) Analyzing code for potential errors and enforcing coding standards
Answer: c) $
Answer: d) <script>src="jquery.js"</script>
Which jQuery function is used to wait for the document to be fully loaded before executing code?
a) $(document).load()
b) $(document).ready()
c) $(document).onload()
d) $(document).load(function)
Answer: b) $(document).ready()
Answer: a) To prevent conflicts with other JavaScript libraries using the same "$" symbol
Answer: a) $("p")
Answer: d) .className()
How can you select an element with the ID "myElement" using jQuery?
a) $("#myElement")
b) "$(myElement)"
c) ".myElement"
d) $("myElement")
Answer: a) $("#myElement")
Answer: b) Actions or occurrences that happen in response to user interactions or browser actions
How do you attach a click event to a button with the ID "myButton" using jQuery?
a) $("myButton").on("click", function() { /* code here / })
b) $("myButton").click(function() { / code here / })
c) $("myButton").event("click", function() { / code here / })
d) $("myButton").addEventListener("click", function() { / code here */ })
Answer: c) .off()
Answer: b) The user hovers over and moves the mouse out of an element
Answer: b) event.preventDefault()
Answer: d) .animate()
How can you make an element bounce up and down using jQuery?
a) $("element").slideUp().slideDown()
b) $("element").fadeIn().fadeOut()
c) $("element").animate({top: "50px"}).animate({top: "0px"})
d) $("element").animate({height: "toggle"})
How can you select the parent element of an element with the ID "myElement" using jQuery?
a) $("myElement").parent()
b) $("#myElement").parent()
c) $("myElement").getParent()
d) $("#myElement").getParent()
Answer: b) $("#myElement").parent()
How can you insert content at the beginning of an element using jQuery?
a) $("element").prepend("content")
b) $("element").after("content")
c) $("element").prependTo("content")
d) $("element").insertBefore("content")
Answer: a) $("element").prepend("content")
Answer: b) Remove all child elements and text content from the selected element
How do you access the value of a data attribute named "data-name" using jQuery?
a) $("element").data("data-name")
b) $("element").attr("data-name")
c) $("element").data-name
d) $("element").attr(data-name)
Answer: b) $("element").attr("data-name")
Answer: d) $.template("compile")
How can you check if an element has a specific CSS class using jQuery?
a) $("element").hasClass("className")
b) $("element").hasClassName("className")
c) $("element").hasClass(className)
d) $("element").find("className")
Answer: a) $("element").hasClass("className")
Answer: c) $("element").is(":hidden")
Answer: b) <script>src="plugin.js"</script>
How can you call a method from a jQuery plugin named "myPlugin" on an HTML element?
a) $("element").myPlugin()
b) $("element").myPlugin.method()
c) myPlugin($("element"))
d) $("element").method(myPlugin)
Answer: a) $("element").myPlugin()
Which of the following is a popular jQuery plugin used for creating image sliders and carousels?
a) jSlider
b) imageZoomer
c) slick
d) galleryMagic
Answer: c) slick
Topic: JSON Data - a Name and a Value, JSON Objects, JSON Arrays, JSON
Files
In JSON, a name and a value are separated by:
a) A colon :
b) A semicolon ;
c) A comma ,
d) A hyphen -
Answer: a) A colon :
Which JSON data structure is used to store an unordered collection of key-value pairs?
a) JSON object
b) JSON array
c) JSON string
d) JSON file
How can you parse a JSON string in JavaScript to create a JavaScript object?
a) JSON.parse(jsonString)
b) jsonString.parseJSON()
c) parseJSON(jsonString)
d) JSON.stringify(jsonString)
Answer: a) JSON.parse(jsonString)
When parsing a JSON string, what happens if the JSON syntax is invalid?
a) The browser automatically corrects the syntax errors
b) The parsing process continues, ignoring any syntax errors
c) An error is thrown, and the parsing process stops
d) The JSON string is converted to a JavaScript string
How do you access the value of a specific key in a parsed JSON object in JavaScript?
a) jsonObject.value
b) jsonObject.key
c) jsonObject["key"]
d) jsonObject.getValue("key")
Answer: c) jsonObject["key"]
Answer: b) Data needs to be transferred between client and server in JSON format
Topic: Ajax
Answer: a) fetch()
Answer: c) Executing JavaScript code without waiting for a response from the server
How does Ajax work to update web pages without requiring a full page reload?
a) It uses Java applets to refresh the page content
b) It reloads the entire web page in the background without the user's knowledge
c) It sends and receives data from the server asynchronously, allowing for partial updates
d) It uses XML to store and retrieve data from the server
Answer: c) It sends and receives data from the server asynchronously, allowing for partial updates
Which Ajax framework is commonly used in combination with jQuery to simplify Ajax requests?
a) AngularJS
b) React
c) Vue.js
d) XMLHttpRequest
Answer: d) XMLHttpRequest
How does an Ajax framework handle the process of sending and receiving data?
a) It automatically sends data without requiring any code from the developer
b) It uses predefined functions and methods to handle the request and response
c) It requires manual configuration of the server-side scripts for each request
d) It relies on the browser's built-in Ajax functionality
Answer: b) It uses predefined functions and methods to handle the request and response
Answer: b) To simplify the process of making Ajax requests and handling responses
Answer: b) The ability to execute JavaScript code without waiting for server responses
Which component of Ajax architecture is responsible for sending and receiving data between the client
and server?
a) Database
b) Browser
c) Web server
d) XMLHttpRequest object
Answer: a) It creates and maintains a connection between the client and server
Answer: c) PHP
Answer: d) A mechanism for exchanging data between the client and server
Which protocol is commonly used for communication between web services and Ajax clients?
a) HTML
b) CSS
c) XML
d) SOAP
Answer: c) XML
How does an Ajax client interact with a web service to retrieve data?
a) By sending a request using the XMLHttpRequest object
b) By executing server-side scripts on the client's browser
c) By embedding the data directly into the HTML page
d) By using a Java applet to communicate with the web service
Which type of data format is commonly used in web services to represent data for Ajax clients?
a) JSON
b) XML
c) JavaScript
d) CSV
Answer: a) JSON
Answer: c) JSON is used to send and receive data between the client and server in a standardized
format
Answer: b) jQuery provides built-in functions and methods for making Ajax requests and handling
responses
Which jQuery method is commonly used to make asynchronous Ajax requests?
a) $.ajax()
b) $.get()
c) $.post()
d) $.load()
Answer: a) $.ajax()
What is the purpose of the "dataType" option in the $.ajax() method in jQuery?
a) To specify the type of animation to be used for Ajax responses
b) To set the time delay between consecutive Ajax requests
c) To define the data format expected in the server response (e.g., JSON or XML)
d) To enable or disable caching of Ajax responses
Answer: c) To define the data format expected in the server response (e.g., JSON or XML)
"Introduction to Node.js":
What is Node.js?
A. A front-end JavaScript framework
B. A back-end JavaScript runtime
C. A database management system
D. A CSS preprocessor
Answer: D. Joyent
Answer: C. JavaScript
Which built-in module is used for handling file system operations in Node.js?
A. http
B. fs
C. path
D. os
Answer: B. fs
Answer: B. fs.readFile()
Answer: A. http
Answer: D. Client-side
In which environment does JavaScript have direct access to the Document Object Model (DOM)?
A. Node.js
B. Command Line Interface (CLI)
C. Server-side
D. Browser
Answer: D. Browser
What is the equivalent of the 'window' object in Node.js for the global scope?
A. global
B. node
C. process
D. document
Answer: A. global
Which environment provides built-in objects like 'window', 'document', and 'navigator'?
A. Node.js
B. Command Line Interface (CLI)
C. Server-side
D. Browser
Answer: D. Browser
Which of the following is NOT a core difference between Browser JS and Node.js?
A. DOM access
B. Asynchronous I/O operations
C. Package management
D. Support for client-side scripting
Why is the 'fs' module used in Node.js but not in Browser JS?
A. 'fs' is used for handling network requests in Node.js.
B. 'fs' is used to interact with the filesystem, which is not available in browser environments.
C. 'fs' is a utility module for calculating cryptographic hashes.
D. 'fs' is used to manipulate the browser's history.
Answer: B. 'fs' is used to interact with the filesystem, which is not available in browser environments.
Answer: C. process
Which environment is generally more suitable for CPU-intensive tasks due to its event-driven, non-
blocking architecture?
A. Node.js
B. Command Line Interface (CLI)
C. Server-side
D. Browser
Answer: A. Node.js
Answer: B. let
Which ES6 feature allows you to declare default values for function parameters?
A. default parameters
B. default args
C. default values
D. default inputs
What is the ES6 feature that facilitates iterating over elements like arrays and objects?
A. loop functions
B. for-of loop
C. forEach loop
D. iterate function
Which ES6 feature is used to handle asynchronous operations more easily using promises?
A. async-await
B. async-promise
C. promise-await
D. promise-async
Answer: A. async-await
Which ES6 feature allows you to create and manage modules in JavaScript?
A. import/export
B. require/module.exports
C. include/extend
D. load/module
Answer: A. import/export
"Node.js REPL":
What does "REPL" stand for in Node.js?
A. Runtime Environment for Processing Language
B. Read Execute Print Loop
C. Real-time Evaluated Programming Language
D. Remote Execution and Programming Logic
How can you access the list of commands and special keys available in the Node.js REPL?
A. Press the "help" key
B. Type "commands" and press Enter
C. Press the Tab key twice
D. There is no built-in list of commands
Answer: A. eval
What does the "_ (underscore)" symbol represent in the Node.js REPL?
A. The current date and time
B. The previous output value
C. The last executed command
D. The current file path
Which command is used to load an external JavaScript file into the Node.js REPL?
A. require
B. load
C. import
D. include
Answer: A. require
What happens when you press the Ctrl + C key combination in the Node.js REPL?
A. It clears the current input.
B. It executes the current input.
C. It exits the Node.js REPL.
D. It displays the list of commands.
Which function is commonly used in Node.js to perform asynchronous operations with callbacks?
A. setTimeout()
B. for...of loop
C. Array.map()
D. Object.keys()
Answer: A. setTimeout()
What is the purpose of the callback function in the asynchronous method 'fs.readFile'?
A. To specify the file to be read.
B. To handle any errors that occur during the file read operation.
C. To define the file read mode (e.g., 'utf-8' or 'binary').
D. To set the file read timeout.
Answer: B. To handle any errors that occur during the file read operation.
What does the 'async' module in Node.js help to mitigate when dealing with callbacks?
A. It provides a way to execute synchronous operations in an asynchronous manner.
B. It automatically handles callback errors, preventing program crashes.
C. It allows for parallel execution of asynchronous tasks to improve performance.
D. It provides a cleaner syntax for working with callbacks and avoiding "Callback Hell."
Answer: D. It provides a cleaner syntax for working with callbacks and avoiding "Callback Hell."
Answer: B. It standardizes the way errors are handled in asynchronous operations with callbacks.
Answer: A. To delay the execution of a callback until the next event loop iteration.
Topic: Promises
What is a Promise in the context of Node.js asynchronous programming?
A. A guarantee that a function will execute immediately.
B. A way to handle synchronous operations without blocking the event loop.
C. An object representing the eventual completion (or failure) of an asynchronous operation.
D. A method for handling errors in synchronous code.
Answer: C. An object representing the eventual completion (or failure) of an asynchronous operation.
Answer: B. .then()
Answer: A. It allows you to handle errors that occur during the Promise's execution.
How can you handle multiple Promises simultaneously and wait for all of them to resolve?
A. Using the '.resolveAll()' method.
B. Using the '.wait()' method.
C. Using the '.all()' method.
D. Using the '.execute()' method.
Answer: C. It waits for a Promise to settle and returns the resolved value.
What is the main benefit of using async/await over traditional Promise chains?
A. async/await provides better performance and faster execution.
B. async/await allows you to avoid handling errors with '.catch()'.
C. async/await automatically converts synchronous code to asynchronous.
D. async/await provides a more readable and synchronous-like syntax.
What happens if an error occurs within an async function and is not caught using 'try...catch'?
A. The error is automatically logged to the console.
B. The Node.js process exits with an error code.
C. The event loop is blocked until the error is resolved.
D. The error propagates up to the nearest rejected Promise.
What is the role of the callback queue in the Event Loop process?
A. It stores JavaScript code for immediate execution.
B. It holds callbacks to be executed after the current stack is empty.
C. It schedules tasks for parallel execution on multiple cores.
D. It manages timers and intervals for asynchronous functions.
What does the term "blocking the event loop" refer to in Node.js?
A. A situation where an infinite loop prevents the event loop from executing other tasks.
B. A situation where the event loop is paused and not executing any code.
C. A situation where synchronous code execution takes too long and delays other tasks.
D. A situation where the event loop cannot handle incoming HTTP requests.
Answer: C. A situation where synchronous code execution takes too long and delays other tasks.
How does the Event Loop handle asynchronous I/O operations in Node.js?
A. It assigns a separate thread for each I/O operation to run in parallel.
B. It queues I/O operations and executes them in the order they complete.
C. It waits for all I/O operations to complete before moving to the next task.
D. It pauses the event loop until all I/O operations are finished.
Answer: B. It queues I/O operations and executes them in the order they complete.
Topic: Timers
Which function is used to delay the execution of a callback in Node.js?
A. setImmediate()
B. setInterval()
C. setTimeout()
D. setTimer()
Answer: C. setTimeout()
What happens when a timer created using setTimeout() is set to a negative or zero delay?
A. The timer is ignored, and the callback is not executed.
B. The timer executes immediately before other tasks in the event loop.
C. The event loop throws an error and terminates.
D. The timer is treated as if it were set to a minimum delay of one millisecond.
Answer: D. The timer is treated as if it were set to a minimum delay of one millisecond.
Which method is used to clear a timer created with setTimeout() before it executes the callback?
A. clearTimeout()
B. clearTimer()
C. stopTimeout()
D. resetTimer()
Answer: A. clearTimeout()
Answer: B. setImmediate() executes the callback before any other timers, while setTimeout() queues
the callback after the specified delay.
Which method is used for asynchronous file reading in the 'fs' module?
A. fs.readFile()
B. fs.read()
C. fs.readFileSync()
D. fs.readSync()
Answer: A. fs.readFile()
Answer: B. It stands for "Synchronous," meaning the method blocks the event loop during execution.
Answer: A. fs.writeFile()
Which method is used to create an HTTP server in Node.js using the 'http' module?
A. http.createServer()
B. http.newServer()
C. http.createServerInstance()
D. http.startServer()
Answer: A. http.createServer()
How can you listen to incoming HTTP requests on an HTTP server in Node.js?
A. Using the 'http.listen()' method.
B. By specifying a callback function with the 'http.createServer()' method.
C. By calling the 'http.on()' method and passing the event name as 'request'.
D. By using the 'http.receive()' method inside the server instance.
What is the purpose of the 'request' and 'response' objects in the 'http' module?
A. The 'request' object holds information about the server, while the 'response' object contains the
client's request.
B. The 'request' object represents the incoming HTTP request from the client, and the 'response' object
is used to send the HTTP response back to the client.
C. The 'request' object contains client-side JavaScript code, while the 'response' object contains server-
side JavaScript code.
D. Both 'request' and 'response' objects represent incoming requests from the client.
Answer: B. The 'request' object represents the incoming HTTP request from the client, and the
'response' object is used to send the HTTP response back to the client.
What HTTP status code is typically sent in the response header to indicate a successful HTTP request?
A. 200 OK
B. 400 Bad Request
C. 404 Not Found
D. 500 Internal Server Error
Answer: A. 200 OK
Understanding the 'fs' and 'http' modules in Node.js is crucial for handling file I/O operations and
creating HTTP servers to manage incoming requests and responses.
Which method is used to create an HTTP server in Node.js using the 'http' module?
A. http.createServer()
B. http.newServer()
C. http.createServerInstance()
D. http.startServer()
Answer: A. http.createServer()
How can you listen to incoming HTTP requests on an HTTP server in Node.js?
A. Using the 'http.listen()' method.
B. By specifying a callback function with the 'http.createServer()' method.
C. By calling the 'http.on()' method and passing the event name as 'request'.
D. By using the 'http.receive()' method inside the server instance.
What is the purpose of the 'request' and 'response' objects in the 'http' module when handling HTTP
requests?
A. The 'request' object holds information about the server, while the 'response' object contains the
client's request.
B. The 'request' object represents the incoming HTTP request from the client, and the 'response' object
is used to send the HTTP response back to the client.
C. The 'request' object contains client-side JavaScript code, while the 'response' object contains server-
side JavaScript code.
D. Both 'request' and 'response' objects represent incoming requests from the client.
Answer: B. The 'request' object represents the incoming HTTP request from the client, and the
'response' object is used to send the HTTP response back to the client.
What HTTP status code is typically sent in the response header to indicate a successful HTTP request?
A. 200 OK
B. 400 Bad Request
C. 404 Not Found
D. 500 Internal Server Error
Answer: A. 200 OK
In the context of an HTTP server, what does the 'method' property of the 'request' object represent?
A. The HTTP status code of the response.
B. The URL path requested by the client.
C. The type of HTTP request method used (e.g., GET, POST, etc.).
D. The headers sent by the client.
Answer: C. The type of HTTP request method used (e.g., GET, POST, etc.).
Which method is used to write a response to the client in the 'http' module's callback function?
A. response.writeResponse()
B. response.send()
C. response.write()
D. response.sendResponse()
Answer: C. response.write()
How can you set the HTTP status code for the response in the 'http' module's callback function?
A. By calling 'response.statusCode()' method.
B. By assigning the status code directly to 'response.code'.
C. By calling 'response.status()' method.
D. By setting 'response.statusCode' property.
Answer: D. The type of data being sent in the response (e.g., JSON, HTML, etc.).
How can you start the HTTP server to listen on a specific port and hostname in Node.js?
A. By calling 'http.listen()' and passing the port and hostname as arguments.
B. By setting the 'http.port' and 'http.hostname' properties before calling 'http.createServer()'.
C. By using 'http.on()' and specifying the 'port' and 'hostname' as event names.
D. By calling 'http.start()' method and passing the port and hostname as arguments.
Answer: A. By calling 'http.listen()' and passing the port and hostname as arguments.
Which method is used to read a file synchronously using the 'fs' module?
A. fs.readFile()
B. fs.read()
C. fs.readFileSync()
D. fs.readSync()
Answer: C. fs.readFileSync()
Answer: B. It stands for "Synchronous," meaning the method blocks the event loop during execution.
Which method is used to write data to a file asynchronously using the 'fs' module?
A. fs.writeFile()
B. fs.write()
C. fs.writeFileSync()
D. fs.writeSync()
Answer: A. fs.writeFile()
Which method is used to create an HTTP server in Node.js using the 'http' module?
A. http.createServer()
B. http.newServer()
C. http.createServerInstance()
D. http.startServer()
Answer: A. http.createServer()
How can you listen to incoming HTTP requests on an HTTP server in Node.js?
A. Using the 'http.listen()' method.
B. By specifying a callback function with the 'http.createServer()' method.
C. By calling the 'http.on()' method and passing the event name as 'request'.
D. By using the 'http.receive()' method inside the server instance.
What is the purpose of the 'request' and 'response' objects in the 'http' module when handling HTTP
requests?
A. The 'request' object holds information about the server, while the 'response' object contains the
client's request.
B. The 'request' object represents the incoming HTTP request from the client, and the 'response' object
is used to send the HTTP response back to the client.
C. The 'request' object contains client-side JavaScript code, while the 'response' object contains server-
side JavaScript code.
D. Both 'request' and 'response' objects represent incoming requests from the client.
Answer: B. The 'request' object represents the incoming HTTP request from the client, and the
'response' object is used to send the HTTP response back to the client.
What HTTP status code is typically sent in the response header to indicate a successful HTTP request?
A. 200 OK
B. 400 Bad Request
C. 404 Not Found
D. 500 Internal Server Error
Answer: A. 200 OK
Developing a Node web application involves using the 'fs' module for file system operations and the
'http' module to handle HTTP requests and responses effectively. Understanding these modules is
crucial for building web applications in Node.js.
Which package manager is commonly used in Node.js for installing dependencies in web applications?
A. npm
B. pip
C. yarn
D. apt-get
Answer: A. npm
Which command is used to create a new Node.js project with the default package.json file?
A. node init
B. npm create
C. npm init
D. node create
Answer: C. A popular framework for building web applications and APIs with Node.js.
What is the purpose of the 'npm start' command in a Node web application?
A. To install all dependencies listed in package.json.
B. To build the application and prepare it for production.
C. To start the web server and run the application.
D. To run automated tests for the application.
Which HTTP method is typically used for retrieving data from a web server in Node.js?
A. GET
B. POST
C. PUT
D. DELETE
Answer: A. GET
What is the purpose of the 'req' and 'res' objects in the context of handling HTTP requests in Node.js?
A. 'req' holds information about the server, and 'res' contains the client's request.
B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the HTTP
response back to the client.
C. 'req' contains client-side JavaScript code, and 'res' contains server-side JavaScript code.
D. Both 'req' and 'res' represent incoming requests from the client.
Answer: B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the
HTTP response back to the client.
How can you handle different routes and HTTP methods in Express.js?
A. By using the 'if-else' statements within the route handlers.
B. By creating separate JavaScript files for each route.
C. By using the 'app.get()', 'app.post()', etc., methods in Express.js.
D. By defining all routes in a single 'index.js' file.
Answer: C. A function that runs before the route handlers and can perform common tasks like
authentication, logging, etc.
Which command is used to install the Express.js framework in a Node web application?
A. npm express install
B. npm i express
C. node install express
D. npm install-express
What is the primary purpose of the 'req' and 'res' objects in Express.js?
A. 'req' holds information about the server, while 'res' contains the client's request.
B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the HTTP
response back to the client.
C. 'req' contains client-side JavaScript code, while 'res' contains server-side JavaScript code.
D. Both 'req' and 'res' represent incoming requests from the client.
Answer: B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the
HTTP response back to the client.
What is the command used to start the development server for an Express.js application?
A. node server.js
B. npm run start
C. npm start
D. express start
Which command is used to start the development server for an Express.js application?
A. node server.js
B. npm run start
C. npm start
D. express start
What is the command to install all the required dependencies specified in the 'package.json' file of an
Express.js application?
A. npm install
B. npm i
C. npm get-deps
D. npm get
Answer: A. npm install
What is the primary purpose of the 'req' and 'res' objects in Express.js?
A. 'req' holds information about the server, while 'res' contains the client's request.
B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the HTTP
response back to the client.
C. 'req' contains client-side JavaScript code, while 'res' contains server-side JavaScript code.
D. Both 'req' and 'res' represent incoming requests from the client.
Answer: B. 'req' represents the incoming HTTP request from the client, and 'res' is used to send the
HTTP response back to the client.
Answer: A. app.get()
What is the purpose of the 'params' object in the 'req' object of Express.js?
A. To store user session information securely.
B. To access data sent in the HTTP request body.
C. To extract route parameters from the URL.
D. To handle cookies and client-side data.
What is the 'send()' method used for in the 'res' object of Express.js?
A. To send an HTTP response with a specific status code.
B. To send an HTTP response with a specific content type.
C. To send a JSON response with data to the client.
D. To send an HTTP response with a custom message.
Which of the following Express.js methods is used for handling errors in middleware or route handlers?
A. app.use()
B. app.error()
C. app.next()
D. app.catch()
Answer: A. app.use()
How can you define a route for an HTTP GET request in Express.js?
A. app.get()
B. app.post()
C. app.route()
D. app.handle()
Answer: A. app.get()
Answer: A. A function that runs before the route handlers to perform common tasks like authentication,
logging, etc.
Which method is used to handle multiple HTTP methods for a single route in Express.js?
A. app.get()
B. app.route()
C. app.all()
D. app.method()
Answer: C. app.all()
What is the purpose of the 'next()' function in middleware or route handlers in Express.js?
A. To terminate the current request and response cycle.
B. To pass control to the next matching route or middleware.
C. To send an HTTP response to the client.
D. To retrieve data from the request body.
Which Express.js method is used to define a middleware function that applies to all routes in the
application?
A. app.use()
B. app.apply()
C. app.all()
D. app.middleware()
Answer: A. app.use()
Answer: C. A library that renders dynamic HTML views using data and templates.
Which of the following template engines is commonly used with Express.js?
A. React
B. Handlebars
C. AngularJS
D. Vue.js
Answer: B. Handlebars
How can you set the template engine for an Express.js application to use Handlebars?
A. app.engine('handlebars')
B. app.set('view engine', 'handlebars')
C. app.use('handlebars')
D. app.template('handlebars')
Which directory is commonly used in an Express.js application to store the templates and views?
A. /static
B. /views
C. /templates
D. /public
Answer: B. /views
How can you pass data from the server to the view when rendering a template in Express.js?
A. By using the 'res.send()' method in the route handler.
B. By defining the data in the 'req' object before rendering the view.
C. By passing an object with data as the second argument to 'res.render()'.
D. By setting the 'data' property in the 'app.locals' object.
What is React?
A. A programming language for building web applications.
B. A front-end JavaScript framework for creating user interfaces.
C. A back-end framework for handling server-side logic.
D. A database management system for storing and retrieving data.
What are the key features of React that make it popular for building user interfaces?
A. Two-way data binding and automatic DOM manipulation.
B. Support for server-side rendering and code splitting.
C. Virtual DOM and component-based architecture.
D. Integrated package manager and command-line interface.
Which JavaScript library did Facebook develop that later served as the foundation for React?
A. jQuery
B. Backbone.js
C. AngularJS
D. XHP
Answer: D. XHP
What is the primary advantage of using React for building user interfaces?
A. It provides an intuitive and easy-to-learn syntax.
B. It offers built-in support for server-side rendering.
C. It is compatible with all major browsers and platforms.
D. It efficiently updates and re-renders only the necessary parts of the DOM.
Answer: D. It efficiently updates and re-renders only the necessary parts of the DOM.
Answer: A. npm
What is the command used to create a new React application using Create React App?
A. react new my-app
B. create-react-app my-app
C. npm init react-app my-app
D. npx create-react my-app
How can you start the development server for a React application?
A. npm run dev
B. npm start
C. react start
D. react-scripts start
Answer: A. /src
Answer: D. To load the React application into the browser and mount it to a DOM element.
Answer: C. Elements represent components and other DOM elements, while components define the
user interface.
Answer: A. To render a React component into the DOM at a specified container element.
Answer: A. React.createElement()
What is the difference between a function component and a class component in React?
A. Function components are more performant than class components.
B. Class components can use lifecycle methods, while function components cannot.
C. Function components are stateful, while class components are stateless.
D. Class components are created using ES6 classes, while function components are regular JavaScript
functions.
Answer: B. Class components can use lifecycle methods, while function components cannot.
Answer: C. By passing data as props when rendering the child component in the parent component.
How can you access and use the 'props' object in a class component?
A. By using the 'this.props' keyword in the render method of the component.
B. By importing the 'props' object from the 'react' module at the beginning of the component file.
C. By using the 'props' keyword as a parameter of the component's constructor function.
D. By defining a 'props' variable using the 'let' keyword within the component's scope.
Answer: A. By using the 'this.props' keyword in the render method of the component.
Answer: B. The component is re-rendered with the new props, and the DOM is updated.
Answer: C. The practice of creating a new component by using existing components as building blocks.
Answer: C. A function that takes a component and returns a new enhanced component.
How can you use a higher-order component (HOC) to share functionality between multiple
components?
A. By nesting components inside each other in the JSX markup.
B. By wrapping components with the HOC function before exporting them.
C. By defining the shared functionality in a separate JavaScript file and importing it into each
component.
D. By using the 'extends' keyword to create a subclass that inherits the functionality from the HOC.
Answer: B. By wrapping components with the HOC function before exporting them.
Answer: C. To access and render the content placed between the opening and closing tags of a
component.
Answer: A. To define the structure and layout of the component's JSX markup.
What happens if the 'render()' method returns 'null' or 'false' in a React component?
A. The component is rendered normally with an empty content.
B. The component throws an error and stops rendering.
C. The component is not rendered, and nothing is displayed.
D. The component's 'render()' method is called again with new props.
Which lifecycle method is used to perform additional actions after the component is rendered to the
DOM?
A. componentDidUpdate()
B. componentWillUnmount()
C. componentWillReceiveProps()
D. componentDidMount()
Answer: D. componentDidMount()
Answer: C. To force the component to re-render immediately, even if props and state haven't changed.
Answer: B. To simplify components by breaking them into smaller, more focused pieces.
Answer: A. It reduces the size of the application's bundle and improves loading times.
How can you declutter components in a React application effectively?
A. By combining multiple components into a single, more complex component.
B. By removing all higher-order components (HOCs) and reusing the same logic in each component.
C. By using a component library that provides pre-built, generic components for all use cases.
D. By breaking larger components into smaller, reusable components with specific responsibilities.
Answer: D. By breaking larger components into smaller, reusable components with specific
responsibilities.
What is the advantage of using a state management library like Redux in decluttering components?
A. It automatically optimizes the rendering process and reduces unnecessary re-renders.
B. It provides a centralized store for managing application state, reducing props drilling.
C. It allows components to access data directly from the server without using props.
D. It eliminates the need for using React's built-in context API for component communication.
Answer: B. It provides a centralized store for managing application state, reducing props drilling.
Answer: C. A local data store used for managing data within a component.
Answer: B. constructor()
Answer: A. The component is re-rendered, and the DOM is updated to reflect the new state.
Which lifecycle method is used to perform actions when a component is first mounted to the DOM?
A. componentDidUpdate()
B. componentWillUnmount()
C. componentDidMount()
D. componentWillMount()
Answer: C. componentDidMount()
What is the purpose of the 'setState()' method in React components?
A. To create a new state object with updated data.
B. To replace the current state with a new state object.
C. To update the component's props with new data.
D. To toggle between different component states.
In a React component, can you directly modify the state object without using 'setState()' method?
A. Yes, you can modify the state object directly.
B. No, direct modification of the state object is not recommended and may not trigger a re-render.
C. Yes, but only if the state object is a primitive data type like a string or number.
D. No, direct modification of the state object is allowed only within the 'constructor()' method.
Answer: B. No, direct modification of the state object is not recommended and may not trigger a re-
render.
Answer: B. When the component needs to manage and update its local data.
Answer: B. A component that manages its own local state using 'setState()' method.
Which lifecycle method is used to decide whether the component should update or not?
A. componentDidUpdate()
B. shouldComponentUpdate()
C. componentWillUpdate()
D. getSnapshotBeforeUpdate()
Answer: B. shouldComponentUpdate()
Answer: B. To perform cleanup tasks and free up resources used by the component.
Which lifecycle method is used to capture information about the DOM before it is updated?
A. componentDidUpdate()
B. shouldComponentUpdate()
C. componentWillUpdate()
D. getSnapshotBeforeUpdate()
Answer: D. getSnapshotBeforeUpdate()
Answer: B. After the component's state or props have changed, and the component is re-rendered.
In which lifecycle method should you fetch data from an external API or server?
A. componentDidMount()
B. componentWillMount()
C. componentWillReceiveProps()
D. componentDidUpdate()
Answer: A. componentDidMount()
What happens if you call 'setState()' inside the 'render()' method of a component?
A. It throws an error, as 'setState()' should only be called outside the 'render()' method.
B. It updates the component's state, triggering a re-render, and may cause an infinite loop.
C. It has no effect on the component's state and rendering process.
D. It returns a new state object, but it doesn't update the component.
Answer: B. It updates the component's state, triggering a re-render, and may cause an infinite loop.
Answer: A. Props are used for communication between parent and child components, while state is
used for managing local data within a component.
Answer: A. To manage the global state of the application and share data across all components.
Answer: C. By using the 'contextType' property in the component and assigning the desired context.
What is the primary use case for the 'Context API' in React?
A. To avoid using props and state and handle all data directly from the context.
B. To simplify component communication and avoid prop drilling.
C. To share styling and layout information across multiple components.
D. To replace Redux and other state management libraries in React applications.
Answer: B. When you need to manage local data that can change over time within a component.
Answer: A. The child components receive the updated state automatically without any additional code.
Answer: A. 'State' is used to manage local component data, while 'context' is used for communication
between parent and child components.
Answer: A. {this.handleEvent}
Which of the following events is triggered when the user clicks on an HTML element?
A. onMouseEnter
B. onKeyPress
C. onClick
D. onChange
Answer: C. onClick
Answer: B. Yes, by using the 'event' keyword inside the event handler function.
Which event is triggered when a user types a character in an input field in React?
A. onKeyDown
B. onFocus
C. onChange
D. onInput
Answer: C. onChange
Answer: B. Defining event handlers outside the component and passing them as props.
Answer: B. The practice of rendering different components based on specific conditions or states.
Which conditional rendering approach allows you to conditionally render multiple components
together?
A. Using the 'if-else' statement within the 'render()' method.
B. Using the 'switch' statement within the 'render()' method.
C. Using the 'map' method to iterate over an array of components and render them conditionally.
D. Using the 'ternary' operator (also known as the conditional operator).
Answer: C. Using the 'map' method to iterate over an array of components and render them
conditionally.
In conditional rendering, what will be rendered if none of the conditions are met?
A. The component will throw an error and stop rendering.
B. The component will render a default message or fallback content.
C. The component will automatically re-render with default props.
D. The component will be removed from the DOM.
Answer: D. Using the 'ternary' operator and concise expressions for clean and readable code.
Answer: A. To ensure that each list item has a unique identifier and prevent duplicates.
Answer: C. The list items will lose their position and order when re-rendered.
Which of the following elements should have keys when used in lists?
A. All elements in the list.
B. The first element in the list.
C. The last element in the list.
D. Only elements with unique data.
Answer: A. All elements in the list.
What is the best practice for selecting keys for list items in React?
A. Using the index of the item as the key.
B. Using random strings as keys to ensure uniqueness.
C. Using the item's ID or a unique identifier from the data as the key.
D. Using the parent component's state as the key.
Answer: C. Using the item's ID or a unique identifier from the data as the key.
What is the purpose of using the 'map()' method when rendering multiple components in React?
A. To iterate over an array of components and render them as siblings.
B. To transform data and update the state of the components.
C. To apply styles and layout to the components.
D. To sort the components based on specific criteria.
In React, how can you conditionally render multiple components based on certain criteria?
A. By using the 'if-else' statement inside the 'map()' method.
B. By using the 'switch' statement inside the 'map()' method.
C. By using the 'ternary' operator inside the 'map()' method.
D. By using the 'filter()' method to create a new array of components.
What happens if you try to render an array of components without a unique key for each item?
A. React will automatically assign keys based on the order of the items in the array.
B. The components will be rendered without any issues, and no key is required.
C. React will throw a warning, but the components will still be rendered.
D. React will throw an error, and the components will not be rendered.
Answer: C. React will throw a warning, but the components will still be rendered.
In React, can you render components conditionally based on the index of the array element?
A. Yes, you can use the 'if-else' statement to conditionally render components based on the index.
B. No, React doesn't support conditional rendering based on the index of the array element.
C. Yes, you can use the 'map()' method with the index parameter to conditionally render components.
D. Yes, but you need to use the 'filter()' method first to get the specific element and then render the
component.
Answer: C. Yes, you can use the 'map()' method with the index parameter to conditionally render
components.
Answer: B. By using 'props' to pass the data from the parent component to the list component.
Which lifecycle method of the list component is commonly used to initialize state and fetch data?
A. componentWillMount()
B. componentDidMount()
C. componentDidUpdate()
D. componentWillUnmount()
Answer: B. componentDidMount()
In a basic list component, where should you usually perform data fetching from an external API?
A. In the 'constructor()' method of the component.
B. In the 'render()' method of the component.
C. In the 'componentDidMount()' method of the component.
D. In a separate helper function outside the component.
How can you handle user interactions with the items in a basic list component?
A. By using event listeners within the 'render()' method.
B. By attaching event handlers to the 'onClick' event of each list item.
C. By using 'state' to manage the selected items in the list.
D. By creating separate components for each list item with their event handlers.
Answer: B. By attaching event handlers to the 'onClick' event of each list item.
Answer: A. By using the 'onSubmit' event on the form element and providing a callback function.
In React, how can you handle multiple input elements in a form with a single event handler?
A. By creating separate event handlers for each input element.
B. By using the 'event.currentTarget.value' within the event handler.
C. By defining a 'name' attribute on each input element and using it in the event handler.
D. By using 'props' to pass the input values from child components to the parent component.
Answer: C. By defining a 'name' attribute on each input element and using it in the event handler.
Answer: A. 'Refs' are a way to reference DOM elements directly within a component.
Answer: C. It centralizes state management and makes it easier to share data between components.
Answer: C. When multiple components share the same state that needs to be synchronized.
Answer: C. Centralizing state management in a higher-level component and passing it down to child
components.
Answer: B. To handle errors that occur during rendering or in lifecycle methods of components.
Answer: C. The error is caught and handled by the error boundary, and an alternative UI is shown.
Answer: C. Yes, you can have multiple error boundaries at different levels of the component tree.
What is the recommended approach for handling errors inside an error boundary in React?
A. Displaying a fallback UI with an error message.
B. Logging the error to the console and rethrowing it.
C. Rendering a blank screen until the error is fixed.
D. Triggering a full page reload to reset the application state.
Answer: C. Inheritance is the process of creating child components by extending parent components.
Answer: A. Composition allows for code reuse and flexibility, while inheritance promotes tight
coupling between components.
Answer: B. Composition allows for more flexible and maintainable component hierarchies.
Answer: C. Inheritance can result in tightly coupled components, making it harder to maintain and
refactor.
Topic: Containment
Answer: C. Containment is the act of passing components as children to another component in the JSX
markup.
In React, how can you pass components as children to another component for containment?
A. By using the 'this.props.children' prop to access the child components in the parent component.
B. By using the 'render' prop to render the child components within the parent component.
C. By using the 'inheritChildren' prop in the parent component to inherit the child components.
D. By using the 'container' prop in the child component to specify the parent component.
Answer: A. By using the 'this.props.children' prop to access the child components in the parent
component.
In React, what can you do with the child components received through containment?
A. You can only render the child components as they are within the parent component.
B. You can manipulate the props and state of the child components within the parent component.
C. You can clone and modify the child components before rendering them within the parent component.
D. You can only pass the child components down to other child components.
Answer: C. You can clone and modify the child components before rendering them within the parent
component.
How can you specify default content to be displayed inside a container component when no children
are provided?
A. By using conditional rendering within the container component.
B. By setting default values for the child components in the parent component's state.
C. By using the 'this.props.children' prop and providing default children in the JSX markup.
D. By using the 'defaultChildren' prop in the container component.
Answer: C. By using the 'this.props.children' prop and providing default children in the JSX markup.
Answer: A. It provides utility methods for working with the 'this.props.children' prop.
What happens if you provide multiple child components to a container component through containment?
A. React throws an error and asks you to provide only one child component.
B. React automatically renders all the child components in the order they are provided.
C. React wraps the child components in an array and passes them as a single child array.
D. React renders only the first child component and ignores the rest.
Answer: C. React wraps the child components in an array and passes them as a single child array.
Answer: B. When you want to render multiple components as children within a parent component.
Topic: Specialization
Answer: C. Specialization is the technique of creating components that focus on specific functionality
or behavior.
Answer: B. Specialized components are easier to maintain and understand due to their focused nature.
Answer: A. By defining separate components for each specific functionality or use case.
Answer: A. HOCs are used to wrap components with additional behavior or data.
Answer: D. When you want to create focused and reusable components for specific use cases.
Answer: B. A 'Modal' component that handles pop-up modals and dialog boxes.
Answer: B. Thinking in React means thinking in terms of components and their composition to build
UIs.
What are the key steps in "thinking in React" for building UIs?
A. Start with building the entire application UI and then refactor into smaller components.
B. Start by identifying the user interface and then determine the component hierarchy.
C. Start by creating the most complex components first and then build the simpler ones.
D. Start by defining state and props for the components and then design the UI.
Answer: B. Start by identifying the user interface and then determine the component hierarchy.
Answer: A. Identify the data that changes over time and needs to be managed by the state.
Answer: B. Determine the props needed for each component and how they are passed from parent to
child.
In "thinking in React," what is the third step in determining component hierarchy?
A. Determine the components that can be combined into a higher-order component.
B. Determine the parent and child components based on data flow and dependency.
C. Determine the components that can be refactored into functional components.
D. Determine the components that can be rendered conditionally based on user interactions.
Answer: B. Determine the parent and child components based on data flow and dependency.
Answer: B. Components enable code reuse and modular development, making the application easier to
maintain.
Answer: D. CDD emphasizes building the UI incrementally, starting with simple components and then
adding complexity.
What are some advantages of "thinking in React" and using a component-driven approach?
A. Faster development and reduced time to market.
B. Improved application performance and reduced memory usage.
C. Easier code maintainability and better separation of concerns.
D. Better compatibility with older versions of React and legacy browsers.
Question: Which Redux method is used to update the state after an action is dispatched?
a) setState()
b) updateState()
c) dispatch()
d) reducer()
Answer: c) dispatch()
Question: How do you combine multiple reducers into a single reducer in Redux?
a) Use the combineReducers() function from Redux.
b) Concatenate the reducer functions manually.
c) Reducers cannot be combined in Redux.
d) Use the mergeReducers() function from React-Redux.
Answer: a) Use the combineReducers() function from Redux.
Question: How can you access the current state held in the Redux store?
a) Using the store.state property
b) By calling the getState() method on the store
c) By invoking the store.dispatch() method
d) By accessing the state prop in React components directly
Answer: b) By calling the getState() method on the store
Question: How does the Redux store notify the React components about the state changes?
a) By calling the componentDidUpdate() lifecycle method
b) Through the store.subscribe() method
c) By dispatching an additional "state-changed" action
d) React components are automatically aware of the state changes in the store
Answer: b) Through the store.subscribe() method
Subtopic: Usage with React
Question: How do you map the Redux state to the props of a connected React component?
a) Using the store.map() method
b) By directly accessing the state object in the component
c) By defining the mapStateToProps() function
d) By setting the stateToProps attribute on the component
Answer: c) By defining the mapStateToProps() function
Question: How can you access the action creators in a React component using React-Redux?
a) By defining a method called actionCreators() in the component
b) By directly importing and calling the action creators from the component
c) By defining a mapActionToProps() function
d) Action creators cannot be accessed in React components.
Answer: b) By directly importing and calling the action creators from the component
Question: What does the connect() function return when used with a React component?
a) A new instance of the component with the Redux store bound to it
b) A higher-order component (HOC) that wraps the original component
c) An object containing the Redux state and action creators as props
d) An error indicating that the component is not connected properly
Answer: b) A higher-order component (HOC) that wraps the original component
Question: Which part of the Redux store state should you typically pass to the React component as
props?
a) The entire Redux store object
b) Only the required state properties needed by the component
c) The entire state tree along with all reducers
d) The action creators used in the component
Answer: b) Only the required state properties needed by the component
Question: When using React-Redux, how can you ensure that a connected component does not re-
render unnecessarily?
a) By using the React.memo() function on the component
b) By setting the shouldComponentUpdate lifecycle method
c) By defining a shouldUpdateComponent() function
d) React-Redux automatically handles unnecessary re-renders for connected components
Answer: a) By using the React.memo() function on the component
Introduction of UI Scripting:
Q1. What does UI stand for in "UI Scripting"?
a) User Integration
b) Universal Interface
c) User Interface
d) Unified Implementation
Answer: c) User Interface
Q2. UI scripting is primarily concerned with:
a) Server-side code development
b) Database management
c) Designing user interfaces and interactions
d) Network security
Answer: c) Designing user interfaces and interactions
Q3. Which term refers to designing and developing different versions of a website for different devices?
a) Dynamic web design
b) Adaptive web design
c) Static web design
d) Responsive web design
Answer: b) Adaptive web design
Q5. Which CSS property is commonly used to make images and other media adapt to the screen size?
a) float
b) display
c) position
d) max-width
Answer: d) max-width
Bootstrap:
Q1. What is Bootstrap?
a) A programming language
b) An operating system
c) A front-end web development framework
d) A database management system
Answer: c) A front-end web development framework
Q2. What is the main purpose of using Bootstrap?
a) To create responsive web designs
b) To manage server-side operations
c) To write complex algorithms
d) To secure the website from external threats
Answer: a) To create responsive web designs
Q3. Which HTML, CSS, and JavaScript framework is the basis of Bootstrap?
a) jQuery
b) AngularJS
c) React
d) Twitter Bootstrap
Answer: d) Twitter Bootstrap
Q5. Which CSS class is used to create a responsive, fixed-width container in Bootstrap?
a) .container-fixed
b) .container-fluid
c) .container-full
d) .container-responsive
Answer: b) .container-fluid
Q3. How many columns are there in a default Bootstrap grid system?
a) 10
b) 12
c) 16
d) 8
Answer: b) 12
Q4. To create a full-width (100% width) element in Bootstrap, which class should be used?
a) .container
b) .full-width
c) .container-fluid
d) .row-full
Answer: c) .container-fluid
Q5. How can you create a two-column layout where the left column occupies 2 grid units, and the right
column occupies 10 grid units?
a) <div class="col-2 col-10">
b) <div class="col-2"><div class="col-10">
c) <div class="col-2"> and <div class="col-10">
d) <div class="col-2" class="col-10">
Answer: c) <div class="col-2"> and <div class="col-10">
Typography:
Q1. Typography in web design refers to:
a) The choice and arrangement of fonts on a website
b) The process of converting text to images
c) The use of bold colors and graphics
d) The inclusion of multimedia elements on a website
Answer: a) The choice and arrangement of fonts on a website
Q2. Which CSS property is used to control the spacing between lines of text?
a) text-spacing
b) line-spacing
c) letter-spacing
d) word-spacing
Answer: b) line-spacing
Q4. Which Bootstrap class is used to emphasize text by making it bold and larger?
a) .emphasize
b) .lead
c) .jumbotron
d) .highlight
Answer: b) .lead
Q5. Which CSS property is commonly used to control the alignment of text within an element?
a) align-text
b) text-align
c) align-content
d) text-style
Answer: b) text-align
Q3. Which programming languages are commonly used in combination with Bootstrap?
a) HTML and JavaScript
b) C++ and Python
c) Java and PHP
d) Ruby and SQL
Answer: a) HTML and JavaScript
Q5. What is the primary advantage of using Bootstrap for web development?
a) It reduces the need for server-side scripting
b) It automatically optimizes the website for SEO
c) It saves development time and effort by providing ready-to-use components
d) It eliminates the need for using JavaScript in web development
Answer: c) It saves development time and effort by providing ready-to-use components
Q3. To create a two-column layout using Bootstrap, how many grid units should each column occupy?
a) 2
b) 4
c) 6
d) 12
Answer: b) 4
Q4. What is the class name for creating a column that spans across all 12 grid units?
a) .col-12
b) .col-span-12
c) .col-full
d) .col-max
Answer: a) .col-12
Q5. How can you create a responsive layout in Bootstrap using columns?
a) By setting a fixed width for each column
b) By hiding certain columns on specific devices using CSS
c) By using different media queries for each column
d) By using Bootstrap's grid classes, which automatically adjust column sizes based on screen size
Answer: d) By using Bootstrap's grid classes, which automatically adjust column sizes based on screen
size
Typography:
Q1. Which aspect of typography does Bootstrap mainly focus on?
a) Font size and style
b) Page layout and alignment
c) Color schemes and contrast
d) Text content and readability
Answer: a) Font size and style
Q2. How can you create larger, bold text using Bootstrap?
a) Use the <strong> HTML tag
b) Apply the class .big-text
c) Use the <b> HTML tag
d) Apply the class .lead
Answer: d) Apply the class .lead
Q3. Which CSS property in Bootstrap controls the spacing between lines of text?
a) line-height
b) font-spacing
c) text-spacing
d) line-spacing
Answer: a) line-height
Components – Tables, Images, Jumbotron, Wells, Alerts, Buttons, Button Groups, Badges/Labels,
Progress Bars, Pagination, List Groups, Panels, Dropdowns, Collapse, Tabs/Pills, Navbar:
Q1. Which Bootstrap component is used to create a group of navigation links?
a) Buttons
b) List Groups
c) Navbar
d) Progress Bars
Answer: c) Navbar
Q3. Which Bootstrap component is used to display a series of content panels stacked on top of each
other?
a) Progress Bars
b) List Groups
c) Panels
d) Alerts
Answer: c) Panels
Q4. Which Bootstrap component is used to display a notification message to the user?
a) Dropdowns
b) Wells
c) Alerts
d) Badges/Labels
Answer: c) Alerts
Forms, Inputs:
Q1. How can you create a form in Bootstrap?
a) Use the <form> HTML tag with Bootstrap-specific classes
b) Apply the class .form to a container
c) Use the <form-group> HTML tag
d) Apply the class .form-container to a container
Answer: a) Use the <form> HTML tag with Bootstrap-specific classes
Q4. Which Bootstrap class is used to create a styled checkbox or radio button?
a) .checkbox
b) .form-check
c) .input-style
d) .custom-control
Answer: b) .form-check
Q2. Where can developers find ready-to-use Bootstrap themes and templates?
a) They can only be created from scratch
b) They are available for purchase from a specific website
c) They can be found on Bootstrap's official website and various third-party sources
d) They are available exclusively in the Bootstrap documentation
Answer: c) They can be found on Bootstrap's official website and various third-party sources
Q3. What is the advantage of using a Bootstrap template for web development?
a) It guarantees a high search engine ranking
b) It ensures complete responsiveness across all devices
c) It saves development time by providing a pre-designed layout and styles
d) It eliminates the need for writing custom JavaScript code
Answer: c) It saves development time by providing a pre-designed layout and styles
Q4. Which of the following is true about Bootstrap themes and templates?
a) They are all free to use without any restrictions
b) They can only be used for personal projects
c) Some themes may require attribution or a license for commercial use
d) They are only available for mobile web development
Answer: c) Some themes may require attribution or a license for commercial use
Q5. How can you apply a Bootstrap theme to your web project?
a) By including the theme's CSS file in your project's HTML code
b) By modifying the Bootstrap framework's core files
c) By using a server-side script to dynamically apply the theme
d) By embedding the theme's JavaScript directly in your HTML code
Answer: a) By including the theme's CSS file in your project's HTML code
Q4. How can HTTPS (HyperText Transfer Protocol Secure) enhance web security?
a) By reducing website loading speed
b) By encrypting data transmitted between the user's browser and the server
c) By preventing search engines from indexing the website
d) By displaying a website's content in multiple languages
Answer: b) By encrypting data transmitted between the user's browser and the server
Q2. Cross-Site Scripting (XSS) is a type of web security vulnerability that allows attackers to:
a) Bypass firewalls and access sensitive data
b) Execute malicious scripts in users' browsers
c) Manipulate website layout and design
d) Redirect users to a different website
Answer: b) Execute malicious scripts in users' browsers
Q2. What are some security concerns related to using JSON data?
a) The lack of support for popular web browsers
b) The potential for injecting malicious code in JSON objects
c) The limited data size that can be transmitted with JSON
d) The difficulty of integrating JSON with server-side languages
Answer: b) The potential for injecting malicious code in JSON objects
Q4. How can developers prevent Cross-Site Request Forgery (CSRF) attacks?
a) By using HTTPS for all web pages
b) By implementing strong password policies
c) By using CSRF tokens in forms and AJAX requests
d) By restricting access to the website to specific IP addresses
Answer: c) By using CSRF tokens in forms and AJAX requests
Q4. The OWASP Zed Attack Proxy (ZAP) is a tool used for:
a) Defending against Distributed Denial of Service (DDoS) attacks
b) Scanning web applications for security vulnerabilities
c) Managing digital certificates for secure communications
d) Providing secure authentication for users
Answer: b) Scanning web applications for security vulnerabilities
Q5. Which OWASP project provides a standardized set of security requirements for web application
development and verification?
a) OWASP Testing Guide
b) OWASP Web Security Testing Guide
c) OWASP Application Security Verification Standard (ASVS)
d) OWASP Code Review Guide
Answer: c) OWASP Application Security Verification Standard (ASVS)