CSE326 Unit 1 - 6 MCQ
CSE326 Unit 1 - 6 MCQ
A. <lb>
B. <br>
C. <break>
D. <newline>
Answer: B. <br>
4. Which HTML tag is used to define the root element of an HTML document?
A. <html>
B. <root>
C. <main>
D. <doctype>
Answer: A. <html>
A. <ol>
B. <li>
C. <ul>
D. <list>
Answer: C. <ul>
A. Creates a hyperlink
A. encoding
B. charset
C. text-type
D. lang
Answer: B. charset
A. <img>
B. <picture>
C. <image>
D. <media>
Answer: A. <img>
A. <link>
B. <a>
C. <href>
D. <hyper>
Answer: B. <a>
A. <para>
B. <p>
C. <paragraph>
D. <text>
Answer: B. <p>
15. Which tag is used to define the main content of an HTML document?
A. <content>
B. <main>
C. <body>
D. <section>
Answer: C. <body>
A. <table>
B. <grid>
C. <tab>
D. <tbl>
Answer: A. <table>
A. <ol>
B. <li>
C. <ul>
D. <list>
Answer: A. <ol>
19. What is the purpose of the alt attribute in the <img> tag?
20. Which HTML tag is used to emphasize text without implying any importance or relevance?
A. <strong>
B. <em>
C. <bold>
D. <italics>
Answer: B. <em>
22. Which HTML tag is used to create a hyperlink that opens in a new tab or window?
A. <a target="_blank">
B. <link new>
C. <hyper new>
D. <openlink>
D. It specifies a hyperlink.
25. Which HTML tag is used to define a section in a document that is not the main content?
A. <section>
B. <main>
C. <div>
D. <article>
Answer: A. <section>
A. <def>
B. <dt>
C. <dlterm>
D. <definition>
Answer: B. <dt>
29. Which HTML tag is used to define the base font size for the entire document?
A. <basefont>
B. <fontsize>
C. <base>
D. <size>
Answer: A. <basefont>
A. <il>
B. <li>
C. <ol>
D. <listitem>
Answer: B. <li>
34. Which HTML tag is used to define a horizontal rule with a thematic break?
A. <break>
B. <rule>
C. <hr>
D. <line>
Answer: C. <hr>
A. <sub>
B. <sup>
C. <subscript>
D. <lower>
Answer: A. <sub>
37. In HTML, what is the purpose of the nowrap attribute in a table cell?
38. Which HTML tag is used to define the document's character set encoding?
A. <charset>
B. <encoding>
C. <meta charset="">
D. <charcode>
C. It specifies a hyperlink.
40. Which attribute is used to define the source URL of an external script in HTML?
A. script
B. source
C. src
D. link
Answer: C. src
41. What does the HTML attribute alt in the <img> tag provide?
42. Which HTML tag is used to define a hyperlink that links to an email address?
A. <email>
B. <a>
C. <link>
D. <mailto>
Answer: B. <a>
45. Which HTML tag is used to define the header for a group of columns in a table?
A. <thead>
B. <header>
C. <th>
D. <colgroup>
Answer: A. <thead>
A. <navlink>
B. <link>
C. <navbar>
D. <a>
Answer: D. <a>
50. Which HTML tag is used to define a horizontal rule with a thematic break and a caption?
A. <hr>
B. <line>
C. <rule>
D. <hr withcaption>
52. In HTML, which attribute is used to provide a brief description of an item within a list?
A. desc
B. title
C. info
D. description
Answer: B. title
53. What does the HTML attribute colspan in a table cell indicate?
A. <input>
B. <button>
C. <submit>
D. <action>
Answer: B. <button>
D. It specifies a hyperlink.
A. <check>
B. <checkbox>
C. <input type="checkbox">
D. <select>
A. <keyboard>
B. <input type="keyboard">
C. <key>
D. <kbd>
Answer: D. <kbd>
60. What is the purpose of the HTML attribute placeholder in an input field?
D. It specifies a hyperlink.
62. Which HTML attribute is used to provide additional information about an element, typically shown
as a tooltip?
A. info
B. title
C. description
D. tooltip
Answer: B. title
63. In HTML, what does the <canvas> element allow you to do?
D. Specifies a hyperlink
65. Which HTML attribute is used to specify the source URL of a video in the <video> tag?
A. video
B. source
C. url
D. src
Answer: D. src
66. In HTML, what does the <details> tag represent?
D. Specifies a hyperlink
67. Which HTML tag is used to define a hyperlink that links to an external resource, such as a style sheet
or script?
A. <link>
B. <href>
C. <a>
D. <external>
Answer: A. <link>
B. Specifies a hyperlink
D. A metadata section
70. Which HTML tag is used to define a container for an external application or interactive content, such
as a plugin?
A. <embed>
B. <app>
C. <plugin>
D. <container>
Answer: A. <embed>
72. In HTML, what does the <time> element with the datetime attribute represent?
A. <progress>
B. <meter>
C. <status>
D. <bar>
Answer: B. <meter>
76. Which HTML attribute is used to provide alternative text for an image in the <area> tag?
A. alt
B. description
C. text
D. label
Answer: A. alt
B. It specifies a hyperlink.
79. Which HTML tag is used to define a container for an external resource that should be embedded in a
document?
A. <include>
B. <object>
C. <embed>
D. <external>
Answer: B. <object>
80. What is the purpose of the HTML <sub> tag?
B. It specifies a hyperlink.
A. <input type="keyboard">
B. <kbd>
C. <key>
D. <keyboard>
Answer: B. <kbd>
B. It specifies a hyperlink.
86. Which HTML attribute is used to specify the language of the content inside the <script> tag?
A. type
B. lang
C. language
D. src
Answer: B. lang
89. Which HTML tag is used to define the text direction of the content within it?
A. <direction>
B. <rtl>
C. <textdir>
D. <bidi>
Answer: B. <rtl>
A. It creates a hyperlink.
92. In HTML, what is the purpose of the <figure> and <figcaption> elements when used together?
93. Which HTML tag is used to define the base URL for all relative URLs within a document?
A. <url>
B. <base>
C. <root>
D. <home>
Answer: B. <base>
96. Which HTML tag is used to define an ordered list item within a nested list?
A. <nl>
B. <li>
C. <ol>
D. <listitem>
Answer: B. <li>
D. It specifies a hyperlink.
99. Which HTML tag is used to define a container for navigation links in a navigation bar?
A. <navbar>
B. <navlink>
C. <nav>
D. <linkbar>
Answer: C. <nav>
100. What is the purpose of the HTML attribute controls in the <audio> and <video> tags?
101. Which HTML tag is used to define a section that contains metadata about the document, such as
the title and character set?
A. <meta>
B. <head>
C. <title>
D. <metadata>
Answer: B. <head>
103. What is the purpose of the HTML attribute async in the <script> tag?
104. Which HTML tag is used to define a hyperlink that links to an external style sheet?
A. <link>
B. <style>
C. <a>
D. <href>
Answer: A. <link>
Answer: B. It defines a style block containing CSS rules for the document.
107. Which HTML attribute is used to specify the media type of the linked resource in the <link> tag?
A. type
B. media
C. format
D. src
Answer: A. type
B. It defines the base URL for all relative URLs within a document.
Answer: B. It defines the base URL for all relative URLs within a document.
109. What is the purpose of the HTML attribute defer in the <script> tag?
B. It specifies that the script should be executed after the document is parsed.
Answer: B. It specifies that the script should be executed after the document is parsed.
110. Which HTML tag is used to define a container for the main content of a document, excluding
headers, footers, and sidebars?
A. <container>
B. <body>
C. <main>
D. <content>
Answer: C. <main>
111. In HTML, what does the <iframe> tag allow you to do?
D. Specify a hyperlink
113. Which HTML tag is used to define a semantic break in an HTML document, indicating a thematic
change in content?
A. <div>
B. <section>
C. <aside>
D. <hr>
Answer: B. <section>
114. In HTML, what is the purpose of the <details> and <summary> elements when used together?
A. <nav>
B. <navbar>
C. <linkbar>
D. <ul>
Answer: A. <nav>
B. Specifies a hyperlink
119. Which HTML attribute is used to specify the language of the content within the <html> tag?
A. lang
B. language
C. html-lang
D. xml:lang
Answer: A. lang
UNIT 2 MCQ
A) text-color
B) color
C) font-color
D) text-style
Answer: B) color
Question 3: What keyword is used to declare a variable in JavaScript?
A) variable
B) v
C) var
D) declare
Answer: C) var
Question 4: Which HTML tag is used to create a text input field in a form?
A) <input>
B) <text>
C) <textfield>
D) <form-text>
Answer: A) <input>
Question 5: In the CSS box model, which property defines the space between an element's border and
its content?
A) margin
B) padding
C) border-space
D) spacing
Answer: B) padding
B) To display a message
D) To declare a variable
A) layout-mode
B) responsive-layout
C) media-query
D) screen-size
Answer: C) media-query
Question 8: How can you access the value of a property named "age" in a JavaScript object called
person?
A) person.age
B) person["age"]
C) person->age
D) person@age
Answer: B) person["age"]
Question 9: Which HTML5 element is used to define the main content of a document?
A) <main>
B) <content>
C) <body>
D) <section>
Answer: A) <main>
Question 10: What CSS property is used to create a flexible container with equal-width columns?
A) float
B) grid
C) flex
D) column-width
Answer: C) flex
Question 11: What HTML tag is used to create a dropdown list in a form?
A) <select>
B) <dropdown>
C) <list>
D) <input type="dropdown">
Answer: A) <select>
Question 12: Which CSS selector selects all elements of a specific type?
A) *
B) .class
C) #id
D) element
Answer: D) element
Question 13: Which event is triggered when a user clicks on an HTML element?
A) mouseover
B) onhover
C) onclick
D) onselect
Answer: C) onclick
A) <td>
B) <th>
C) <tr>
D) <table-row>
Answer: C) <tr>
Question 15: Which CSS property is used to control the stacking order of elements?
A) layer
B) z-index
C) stack-order
D) order
Answer: B) z-index
Question 16: How do you add a new element to the end of an array in JavaScript?
A) array.add()
B) array.push()
C) array.insert()
D) array.append()
Answer: B) array.push()
Question 17: What CSS property is used to set the width of an element?
A) size
B) width
C) length
D) dimension
Answer: B) width
Question 18: How can you change the text content of an HTML element with the id "myElement" using
JavaScript?
Question 19: What is the purpose of the viewport meta tag in HTML?
Question 20: Which CSS property is used to align items vertically in a flex container?
A) justify-content
B) align-items
C) flex-align
D) flex-vertical
Answer: B) align-items
Question 21: What is the purpose of the catch method in a JavaScript promise?
A) To reject a promise
B) To resolve a promise
Question 22: Which HTML tag is used to set the character encoding for the document?
A) <encoding>
B) <charset>
C) <meta charset="UTF-8">
D) <head>
Answer: C) <meta charset="UTF-8">
Question 23: In CSS, which pseudo-class selects the first child element of its parent?
A) :first-child
B) :first-of-type
C) :child
D) :nth-child(1)
Answer: A) :first-child
Question 24: What is the scope of a variable declared with the let keyword in JavaScript?
A) Global scope
B) Local scope
C) Block scope
D) Function scope
Question 25: Which CSS property is used to specify the duration of a transition effect?
A) transition-timing
B) animation-duration
C) transition-duration
D) timing-function
Answer: C) transition-duration
Question 26: How do you access the value of a nested property in a JavaScript object?
A) object.getProperty("nestedProperty")
B) object[nestedProperty]
C) object.get("nestedProperty")
D) object.property("nestedProperty")
Answer: B) object[nestedProperty]
Question 27: Which HTML tag is used to embed an audio file?
A) <sound>
B) <audio>
C) <music>
D) <media>
Answer: B) <audio>
Question 28: In CSS Grid, which property is used to define the size of columns and rows?
A) grid-size
B) column-row-size
C) grid-template-columns / grid-template-rows
D) size
Question 29: What is the purpose of the let keyword in JavaScript ES6?
A) <nav>
B) <navigate>
C) <links>
D) <navigation>
Answer: A) <nav>
Question 31: Which CSS property is used to specify the name of the animation?
A) animation-name
B) animate
C) animation
D) name
Answer: A) animation-name
Question 32: How do you parse a JSON string into a JavaScript object?
A) parseJSON()
B) JSON.parse()
C) stringifyJSON()
D) JSON.stringify()
Answer: B) JSON.parse()
Question 35: What is the purpose of the arguments object in a JavaScript function?
A) To store the function's return value
Question 36: Which HTML5 element is used to define the footer of a document or section?
A) <footer>
B) <bottom>
C) <end>
D) <section-footer>
Answer: A) <footer>
Question 37: What CSS property is used to align items horizontally in a flex container?
A) justify-content
B) align-items
C) flex-align
D) flex-horizontal
Answer: A) justify-content
Answer: B) A function that is passed as an argument to another function and executed later
A) <movie>
B) <video>
C) <media>
D) <film>
Answer: B) <video>
Question 40: Which CSS property is used to scale an element in both the horizontal and vertical
directions?
A) scale
B) transform-scale
C) transform
D) resize
Answer: C) transform
Answer: C) A way to encapsulate variables within a function and access them later
A) <input type="check">
B) <input type="checkbox">
C) <checkbox>
D) <check>
Question 43: Which CSS property is used to control what happens to content that is too big to fit into an
area?
A) overflow-mode
B) content-overflow
C) overflow
D) text-overflow
Answer: C) overflow
Question 45: Which CSS value for the position property removes an element from the normal document
flow?
A) static
B) relative
C) fixed
D) absolute
Answer: C) fixed
Question 47: What is the purpose of the HTML <meta> tag with the viewport attribute?
A) To set the background color of the document
Question 48: In CSS, which pseudo-element selects the first line of an element?
A) :first-line
B) :line-first
C) ::first-line
D) ::line-first
Answer: C) ::first-line
Question 49: How do you store data in the localStorage object in JavaScript?
A) localStorage.storeData("key", "value");
B) localStorage.setItem("key", "value");
C) localStorage.data("key", "value");
D) localStorage.save("key", "value");
Question 51: Which CSS property is used to create a linear gradient background?
A) background-color
B) gradient-color
C) background-image
D) linear-gradient
Answer: C) `
Question 52: What keyword is used to handle errors in a JavaScript try...catch block?
A) handle
B) catch
C) error
D) exception
Answer: B) catch
Question 53: Which HTML5 element is used to define the header of a document or section?
A) <header>
B) <head>
C) <top>
D) <document-header>
Answer: A) <header>
A) rotate
B) transform-rotate
C) rotate-transform
D) transform
Answer: D) transform
Answer: A) Creates a new array by applying a function to each element of an existing array
Question 56: What does the CSS box-sizing: border-box; property do?
A) Includes the padding and border in the element's total width and height
B) Excludes the padding and border from the element's total width and height
C) Only includes the padding in the element's total width and height
D) Only includes the border in the element's total width and height
Answer: A) Includes the padding and border in the element's total width and height
Question 57: How do you select an element with the id "example" using JavaScript querySelector?
A) querySelector("#example")
B) querySelector(".example")
C) querySelector("example")
D) getElementById("example")
Answer: A) querySelector("#example")
Question 58: Which HTML attribute is used to provide a text alternative for images for accessibility?
A) alt
B) description
C) text-alt
D) image-description
Answer: A) alt
Question 59: What is the default value of the CSS position property?
A) relative
B) fixed
C) absolute
D) static
Answer: D) static
Question 61: Which HTML attribute is used to specify the source of an embedded audio or video file?
A) source
B) media
C) src
D) file
Answer: C) src
Question 62: What does the CSS flex-direction property control in a flex container?
Question 63: How do you set a timeout for a function to execute after 3 seconds in JavaScript?
A) setInterval(myFunction, 3000);
B) timeout(myFunction, 3000);
C) setTimeout(myFunction, 3000);
D) delay(myFunction, 3000);
Answer: C) setTimeout(myFunction, 3000);
Question 64: Which HTML5 element is used to define the main content of an article?
A) <content>
B) <main>
C) <article-main>
D) <article-content>
Answer: B) <main>
Question 65: What is the range of values for the CSS opacity property?
A) 0 to 100
B) 0 to 1
C) 1 to 100
D) -1 to 1
Answer: B) 0 to 1
Answer: B) Removes elements from an array and returns the removed elements
Question 67: What HTML5 element is used to draw graphics on a web page?
A) <drawing>
B) <graphics>
C) <canvas>
D) <paint>
Answer: C) <canvas>
Question 68: What does the CSS line-height property control?
A) Creates a new array with the results of calling a provided function on every element in the array
Question 70: Which attribute is used in HTML to provide a short hint describing the content of an input
field?
A) placeholder
B) hint
C) tooltip
D) description
Answer: A) placeholder
Question 71: How do you set a background image for an element in CSS?
A) background: url("image.jpg");
B) background-img: url("image.jpg");
C) background-image: url("image.jpg");
D) img: url("image.jpg");
D) Creates a new array with the results of calling a provided function on every element
Question 73: In HTML, which element is used to define content aside from the content it is placed in?
A) <sidebar>
B) <note>
C) <aside>
D) <section>
Answer: C) <aside>
Question 74: Which CSS property is used to specify the name of the property you want to transition?
A) transition
B) property
C) transition-property
D) animate
Answer: C) transition-property
Question 75: In JavaScript, how do you get the character at a specified index in a string?
A) string.indexChar(2);
B) string.charAt(2);
C) string.charAtIndex(2);
D) string[2];
Answer: B) string.charAt(2);
Question 76: Which HTML5 element is used to create a disclosure widget from which the user can
obtain additional information or controls?
A) <disclose>
B) <expand>
C) <details>
D) <more-info>
Answer: C) <details>
Question 78: What is the key difference between localStorage and sessionStorage in JavaScript?
C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a single tab
Answer: C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a
single tab
Question 79: In HTML, which element is used to define a set of navigation links?
A) <navigate>
B) <links>
C) <navigation>
D) <nav>
Answer: D) <nav>
Question 80: What is the difference between display: none; and visibility: hidden; in CSS?
A) Both properties hide the element, but visibility: hidden; still occupies space
B) visibility: hidden; hides the element and removes it from the document flow
Answer: A) Both properties hide the element, but visibility: hidden; still occupies space
Question 81: In JavaScript, what does the typeof operator return for the data type of a variable?
Question 82: In HTML, which element is used to represent a specific period in time, typically with a
machine-readable format?
A) <datetime>
B) <timestamp>
C) <date>
D) <time>
Answer: D) <time>
Question 83: What is the default value of the CSS box-sizing property?
A) content-box
B) border-box
C) padding-box
D) margin-box
Answer: A) content-box
Question 84: What is the purpose of the second parameter in the JavaScript splice method?
Question 85: In HTML, which element is used to represent the progress of a task?
A) <loading>
B) <progress-bar>
C) <progress>
D) <task-progress>
Answer: C) <progress>
Question 86: What does the CSS flex-wrap property control in a flex container?
C) The wrapping of flex items when they exceed the container width
Answer: C) The wrapping of flex items when they exceed the container width
Question 88: What content is typically placed inside an HTML <article> element?
A) Navigation links
Question 89: What does the CSS property position: fixed; do?
A) Positions the element relative to its normal position in the document flow
C) Positions the element relative to the viewport, so it stays fixed while scrolling
Answer: C) Positions the element relative to the viewport, so it stays fixed while scrolling
C) Calls a provided function once for each element in the array, in order
D) Creates a new array with the results of calling a provided function on every element
Answer: C) Calls a provided function once for each element in the array, in order
Question 91: What is the purpose of the HTML5 <figure> and <figcaption> elements?
B) To represent a standalone piece of content, such as an image or a video, with an optional caption
Question 92: What effect does the CSS property overflow: hidden; have on an element?
Question 93: How do you get the current date and time in JavaScript?
A) getCurrentDate()
B) new Date()
C) getCurrentTime()
D) getCurrentDateTime()
Question 95: What does the CSS property flex-grow control in a flex container?
Question 96: What is the maximum storage capacity of the localStorage object in most browsers?
A) 5 MB
B) 10 MB
C) 2.5 MB
D) 1 MB
Answer: B) 10 MB
Question 99: How do you generate a random decimal number between 0 (inclusive) and 1 (exclusive) in
JavaScript using Math.random()?
A) Math.random(0, 1);
B) random.decimal(0, 1);
C) Math.random() * 1;
D) Math.randomDecimal();
Answer: C) Math.random() * 1;
Question 104: In the CSS box-shadow property, what does the first length value represent?
A) isArray(variable);
B) isTypeOf(variable, "array");
C) variable.isType("array");
D) Array.isArray(variable);
Answer: D) Array.isArray(variable);
Question 110: What does the CSS property position: relative; do?
A) Positions the element relative to its normal position in the document flow
C) Positions the element relative to the viewport, so it stays fixed while scrolling
Answer: A) Positions the element relative to its normal position in the document flow
Question 111: What are the two phases of event propagation in the DOM?
C) Up and Down
D) In and Out
Answer: A) Capture and Bubble
Question 113: What is the difference between box-sizing: content-box; and box-sizing: border-box;?
A) content-box includes padding and border in the total width and height, while border-box includes
only content
B) content-box includes padding in the total width and height, while border-box includes padding and
border
D) content-box and border-box are not valid values for the box-sizing property
Answer: B) content-box includes padding in the total width and height, while border-box includes
padding and border
B) A Promise that resolves to the Response object representing the completion of the request
Answer: B) A Promise that resolves to the Response object representing the completion of the request
Question 115: Which attribute is used in HTML to provide an accessible name for an element?
A) title
B) aria-label
C) alt
D) role
Answer: B) aria-label
Question 116: What does the CSS property display: flex; do?
A) Turns the element into a block-level container with a flex container inside
B) Turns the element into an inline-level container with a flex container inside
Answer: C) Turns the element into a flex container, making it a block-level container
C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a single tab
D) sessionStorage persists data even after the browser is closed, while localStorage does not
Answer: C) localStorage is accessible across different browser tabs, while sessionStorage is limited to a
single tab
Question 118: Which HTML5 element is used to define the header of a document or section?
A) <header>
B) <head>
C) <top>
D) <document-header>
Answer: A) <header>
Question 119: What is the positioning reference for an element with position: absolute;?
A) The viewport
B) The nearest positioned ancestor
UNIT 3 MCQ
a. <link>
b. <style>
c. <css>
d. <external>
Answer: a. <link>
What does CSS stand for?
a. text-color
b. font-color
c. color
d. text-style
Answer: c. color
a. #header
b. .header
c. header
d. element-header
Answer: a. #header
a. <ol>
b. <ul>
c. <li>
d. <list>
Answer: a. <ol>
What is the purpose of the CSS margin property?
a. <link>
b. <a>
c. <href>
d. <hyperlink>
Answer: b. <a>
a. Text alignment
b. Image positioning
c. Background color
d. Font styling
Which of the following is the correct way to comment out multiple lines in HTML?
a. <!-- This is a comment -->
b. // This is a comment //
c. /* This is a comment */
d. # This is a comment #
b. Create a hyperlink
Which of the following CSS selectors selects all elements of a specific type?
a. #element
b. .element
c. element
d. element
Answer: d. element
a. <mail>
b. <email>
c. <a href="mailto:...">
d. <link to="email:...">
Which HTML tag is used to define the structure of an HTML document, including the title and meta
information?
a. <head>
b. <body>
c. <html>
d. <meta>
Answer: c. <html>
In CSS, what property is used to control the space between lines of text within an element?
a. line-spacing
b. text-spacing
c. line-height
d. text-height
Answer: c. line-height
Which of the following is the correct way to apply an external CSS file to an HTML document using the
<link> tag?
a. <ol>
b. <ul>
c. <li>
d. <list>
Answer: b. <ul>
a. background-color
b. color
c. bgcolor
d. background
Answer: a. background-color
Which CSS property is used for controlling the space between elements in a layout?
a. margin
b. padding
c. spacing
d. border-spacing
Answer: a. margin
Answer: a. Creates a break in the page and moves to the next line
Which of the following is the correct way to include an external JavaScript file in an HTML document?
d. <include script="script.js">
a. <link>
b. <a>
c. <href>
d. <hyperlink>
Answer: b. <a>
c. The window
What is the purpose of the HTML <meta> tag with the charset attribute?
Answer: a. Specifies the character set encoding for the HTML document
Which CSS property is used for changing the style of the cursor when it hovers over an element?
a. cursor-style
b. hover-cursor
c. mouse-cursor
d. cursor
Answer: d. cursor
d. Specifies a hyperlink
a. <table>
b. <tr>
c. <td>
d. <th>
Answer: a. <table>
a. Creating a sidebar
b. Adding a hyperlink
Which of the following is the correct way to apply an inline CSS style?
a. <style>
b. <css>
c. <div style="...">
Answer: d. Defines how the total width and height of an element is calculated
Which HTML tag is used to create a hyperlink to another webpage in a new browser window or tab?
In CSS, what property is used to control the space between the content and the border of an element?
a. border-spacing
b. margin
c. padding
d. spacing
Answer: c. padding
a. Abbreviation or acronym
b. Abstract
c. Absolute
d. Abbreviated link
a. list-style-image
b. list-style-type
c. list-item-style
d. list-bullet-style
Answer: b. list-style-type
b. A section of code
c. A bold text
a. <img>
b. <image>
c. <picture>
d. <img src="...">
Answer: a. <img>
b. visited-color
c. active-color
d. color-visited
Answer: b. visited-color
a. Preformatted text
b. A paragraph
c. A pre-header section
d. A pre-link element
a. <ol>
b. <ul>
c. <li>
d. <list>
Answer: a. <ol>
a. Bold text
a. font-size
b. text-size
c. font-style
d. text-font
Answer: a. font-size
d. Creates a hyperlink
b. Adds a hyperlink
Which HTML tag is used to define an input field for entering a date?
a. <input type="date">
b. <date>
c. <input type="text">
d. <textfield>
a. border-width
b. border-thickness
c. border-size
d. thickness
Answer: a. border-width
Which HTML tag is used for creating a hyperlink to another webpage within the same website?
a. <a href="http://example.com">
b. <a href="/page2.html">
c. <a link="/page2.html">
d. <link href="/page2.html">
d. Creates a sidebar
a. <italic>
b. <i>
c. <em>
d. <italicize>
Answer: c. <em>
a. Definition term
b. Definition description
d. Definition name
a. cursor-style
b. hover-cursor
c. mouse-cursor
d. cursor
Answer: d. cursor
a. <line>
b. <hr>
c. <rule>
d. <horizontal>
Answer: b. <hr>
a. Defines a sidebar
c. Adds a hyperlink
d. Specifies a footer
In CSS, what property is used to control the spacing between lines of text?
a. line-spacing
b. text-spacing
c. line-height
d. text-height
Answer: c. line-height
What is the purpose of the HTML <figcaption> tag?
In CSS, what property is used to change the background color of an element when the user hovers over
it?
a. hover-background-color
b. background-color-hover
c. background-hover
d. background-color
Answer: a. hover-background-color
a. <sub>
b. <sup>
c. <subscript>
d. <baseline>
Answer: a. <sub>
c. Defines a sidebar
d. Adds a hyperlink
a. border-spacing
b. margin
c. padding
d. spacing
Answer: b. margin
Answer: c. Hides the content that overflows both height and width
d. Specifies a sidebar
Which CSS property is used for controlling the alignment of text within an element?
a. text-align
b. text-position
c. alignment
d. text-style
Answer: a. text-align
a. shadow-text
b. text-shadow
c. text-effect
d. text-outline
Answer: b. `text-shadow`
makefile
a. A variable
b. A variant
c. A variation
d. A verified element
makefile
Answer: a. A variable
What is the purpose of the HTML <ruby> tag?
In CSS, what property is used to set the background color of an element when the user hovers over it?
a. hover-background-color
b. background-color-hover
c. background-hover
d. hover-color
Answer: a. `hover-background-color`
Which HTML tag is used for creating a horizontal line with a specific color?
a. <line>
b. <rule>
c. <hr color="...">
d. <horizontal>
sql
a. Keyboard input
b. Key binding
c. Keyboard display
d. Keyboard description
a. <super>
b. <sup>
c. <superscript>
d. <baseline>
Answer: b. `<sup>`
a. Defines a timer
c. Creates a timestamp
In CSS, what property is used to set the color of the text when the user hovers over it?
a. hover-text-color
b. color-hover
c. text-color-hover
d. hover-color
Answer: a. `hover-text-color`
Which HTML tag is used for creating an ordered list with lowercase Roman numerals?
a. <ol style="type: i;">
b. <ol type="I">
d. <ol numeral-type="lower-roman">
In CSS, what property is used to set the height of an element as a percentage of its containing element?
a. height
b. percentage-height
c. height-percentage
d. relative-height
Answer: a. `height`
a. <nav>
b. <navbar>
c. <bar>
d. <navigation>
Answer: a. `<nav>`
csharp
In CSS, what property is used to set the style of the list item marker (bullet or number)?
a. list-style-image
b. list-style-type
c. marker-style
d. item-style
Answer: b. `list-style-type`
a. <code>
b. <pre>
c. <block>
d. <text>
Answer: a. `<code>`
UNIT 4 MCQ
• What does CSS stand for?
o a) Computer Style Sheets
o b) Creative Style Sheets
o c) Cascading Style Sheets
o d) Colorful Style Sheets
o Answer: c
• Which HTML tag is used for creating a hyperlink?
o a) <link>
o b) <a>
o c) <url>
o d) <href>
o Answer: b
• In CSS, what property is used to set the background color of an element?
o a) color
o b) background-color
o c) bgcolor
o d) background
o Answer: b
• What is the purpose of the HTML alt attribute in the <img> tag?
o a) Sets the alignment of the image
o b) Defines the alternative text for the image
o c) Specifies the image source
o d) Controls the image width
o Answer: b
• Which CSS property is used to control the space between elements' outer
edges and the surrounding elements?
o a) margin
o b) padding
o c) spacing
o d) border
o Answer: a
• What is the purpose of the HTML <head> tag?
o a) Defines the main content of the document
o b) Contains metadata about the document
o c) Creates a header section in the document
o d) Specifies the font for the document
o Answer: b
• Which HTML tag is used for creating a line break?
o a) <br>
o b) <lb>
o c) <newline>
o d) <break>
o Answer: a
• In CSS, what is the purpose of the position: relative; property?
o a) Positions the element absolutely
o b) Positions the element relative to its normal position
o c) Removes the element from the normal document flow
o d) Hides the element
o Answer: b
• Which of the following is NOT a valid CSS pseudo-class?
o a) :hover
o b) :active
o c) :visible
o d) :focus
o Answer: c
• What does the acronym URL stand for?
o a) Uniform Resource Locator
o b) Universal Reference Language
o c) User-Defined Resource Locator
o d) Unified Resource Language
o Answer: a
• What does HTML stand for?
o a) Hyper Transfer Markup Language
o b) Hyper Text Markup Language
o c) Hyperlink and Text Markup Language
o d) High-Level Text Markup Language
o Answer: b
• Which HTML tag is used for creating an ordered list?
o a) <ol>
o b) <ul>
o c) <li>
o d) <list>
o Answer: a
• In CSS, what property is used to control the spacing between lines of text?
o a) line-height
o b) spacing
o c) text-spacing
o d) letter-spacing
o Answer: a
• What is the purpose of the CSS z-index property?
o a) Controls the opacity of an element
o b) Controls the stacking order of elements
o c) Sets the width of an element
o d) Defines the zoom level of an element
o Answer: b
• Which of the following is NOT a valid value for the display property in CSS?
o a) block
o b) inline
o c) hidden
o d) vertical
o Answer: d
• What is the purpose of the HTML <meta> tag with the charset attribute?
o a) Defines the character set for the document
o b) Creates a meta description for search engines
o c) Specifies the font charset
o d) Sets the document language
o Answer: a
• Which CSS selector is more specific?
o a) class selector (e.g., .my-class)
o b) ID selector (e.g., #my-id)
o c) Element selector (e.g., p)
o d) Attribute selector (e.g., [type="text"])
o Answer: b
• In HTML, which tag is used for embedding an image?
o a) <img>
o b) <picture>
o c) <image>
o d) <imgsrc>
o Answer: a
• What is the purpose of the CSS box-sizing property?
o a) Sets the color of the box border
o b) Defines the box model for an element
o c) Controls the box shadow
o d) Specifies the box layout
o Answer: b
• Which of the following is the correct way to link an external CSS file to an
HTML document?
o a) <link rel="stylesheet" type="text/css" href="style.css">
o b) <style src="style.css"></style>
o c) <css>style.css</css>
o d) <link href="style.css" type="stylesheet">
o Answer: a
• What does CSS stand for?
o a) Computer Style Sheets
o b) Creative Style Sheets
o c) Cascading Style Sheets
o d) Colorful Style Sheets
o Answer: c
• Which HTML tag is used for creating a hyperlink?
o a) <link>
o b) <a>
o c) <url>
o d) <href>
o Answer: b
• In CSS, what property is used to set the background color of an element?
o a) color
o b) background-color
o c) bgcolor
o d) background
o Answer: b
• What is the purpose of the HTML alt attribute in the <img> tag?
o a) Sets the alignment of the image
o b) Defines the alternative text for the image
o c) Specifies the image source
o d) Controls the image width
o Answer: b
• Which CSS property is used to control the space between elements' outer
edges and the surrounding elements?
o a) margin
o b) padding
o c) spacing
o d) border
o Answer: a
• What is the purpose of the HTML <head> tag?
o a) Defines the main content of the document
o b) Contains metadata about the document
o c) Creates a header section in the document
o d) Specifies the font for the document
o Answer: b
• Which HTML tag is used for creating a line break?
o a) <br>
o b) <lb>
o c) <newline>
o d) <break>
o Answer: a
• In CSS, what is the purpose of the position: relative; property?
o a) Positions the element absolutely
o b) Positions the element relative to its normal position
o c) Removes the element from the normal document flow
o d) Hides the element
o Answer: b
• Which of the following is NOT a valid CSS pseudo-class?
o a) :hover
o b) :active
o c) :visible
o d) :focus
o Answer: c
• What does the acronym URL stand for?
o a) Uniform Resource Locator
o b) Universal Reference Language
o c) User-Defined Resource Locator
o d) Unified Resource Language
o Answer: a
• In HTML, which tag is used for creating a table?
o a) <table>
o b) <tab>
o c) <tr>
o d) <td>
o Answer: a
• Which CSS property is used for adding shadows to text?
o a) text-shadow
o b) shadow
o c) font-shadow
o d) box-shadow
o Answer: a
• What is the purpose of the HTML <nav> element?
o a) Defines a navigation menu
o b) Specifies a new navigation page
o c) Creates a navigation link
o d) Defines a navigation bar
o Answer: a
• In CSS, how can you select all the elements with a class name "example"?
o a) .example
o b) #example
o c) element.example
o d) example
o Answer: a
• What is the default value of the CSS position property?
o a) absolute
o b) relative
o c) fixed
o d) static
o Answer: d
• Which HTML tag is used for creating a form?
o a) <form>
o b) <input>
o c) <button>
o d) <label>
o Answer: a
• In CSS, what does the float property do?
o a) Makes an element float to the left or right
o b) Adds a floating effect to an element
o c) Floats an element above other elements
o d) Makes an element semi-transparent
o Answer: a
• What does the HTML <aside> element represent?
o a) A footer section
o b) A side note or content that is tangentially related to the content around it
o c) A header section
o d) An article or content that is independent of the surrounding content
o Answer: b
• Which CSS property is used to set the size of the font?
o a) text-size
o b) font-size
o c) size
o d) text-font
o Answer: b
• What is the purpose of the HTML <article> element?
o a) Defines an article
o b) Creates a section in the document
o c) Represents a side note or additional information
o d) Defines a container for navigation links
o Answer: a
• In CSS, what is the purpose of the max-width property?
o a) Sets the maximum width of an element
o b) Sets the minimum width of an element
o c) Controls the width of the document
o d) Specifies the maximum width of the viewport
o Answer: a
• What is the purpose of the HTML target attribute in the <a> tag?
o a) Specifies the URL of the link
o b) Defines the target audience of the link
o c) Controls how the link should open
o d) Sets the position of the link
o Answer: c
• Which CSS property is used to create space around an element's content,
inside of any defined borders?
o a) margin
o b) padding
o c) spacing
o d) border-spacing
o Answer: b
• In HTML, what does the <figure> element represent?
o a) A group of images
o b) A caption for an image or illustration
o c) A figure or image with a caption
o d) A container for navigation links
o Answer: c
• Which CSS property is used to change the text color of an element?
o a) text-color
o b) color
o c) font-color
o d) text-style
o Answer: b
• What is the purpose of the HTML target attribute in the <form> tag?
o a) Specifies the method of the form
o b) Defines the target audience of the form
o c) Controls how the form data should be submitted
o d) Sets the position of the form
o Answer: c
• In CSS, what does the opacity property control?
o a) The size of an element
o b) The transparency of an element
o c) The shadow of an element
o d) The color of an element
o Answer: b
• Which HTML tag is used for creating an input field for entering a date?
o a) <input type="text">
o b) <input type="date">
o c) <date>
o d) <input type="datetime">
o Answer: b
• What is the purpose of the CSS flexbox layout model?
o a) To create a grid layout
o b) To create a flexible box model for layout design
o c) To control the font size
o d) To add shadows to text
o Answer: b
• In HTML, what does the <blockquote> element represent?
o a) A block of code
o b) A block-level quotation
o c) A block of text with a specific style
o d) A block of images
o Answer: b
• Which CSS property is used to change the style of the cursor when hovered
over an element?
o a) cursor-style
o b) pointer-style
o c) hover-cursor
o d) cursor
o Answer: d
• In CSS, what is the purpose of the transition property?
o a) Adds a transition effect to an element
o b) Sets the transition duration
o c) Controls the timing function of a transition
o d) All of the above
o Answer: d
• What is the purpose of the HTML datetime attribute in the <time> tag?
o a) Specifies the time zone
o b) Defines the date and time
o c) Sets the font size
o d) Controls the text alignment
o Answer: b
• Which HTML tag is used for creating a dropdown list?
o a) <dropdown>
o b) <select>
o c) <list>
o d) <options>
o Answer: b
• In CSS, what is the purpose of the box-shadow property?
o a) Adds a shadow to an element
o b) Sets the background color of an element
o c) Controls the width of an element
o d) Defines the box model for an element
o Answer: a
• What does the acronym API stand for in web development?
o a) Advanced Programming Interface
o b) Application Programming Interface
o c) Advanced Protocol Integration
o d) Application Protocol Interface
o Answer: b
• Which HTML tag is used for creating a checkbox?
o a) <checkbox>
o b) <input type="checkbox">
o c) <check>
o d) <input type="check">
o Answer: b
• Which of the following is NOT a valid CSS unit for specifying length?
o a) px (pixels)
o b) em
o c) pt (points)
o d) ex
o Answer: d
• What is the purpose of the HTML <iframe> element?
o a) Defines an inline frame for embedding external content
o b) Creates a floating image
o c) Specifies the font style for text
o d) Defines an internal frame for navigation
o Answer: a
• In CSS, what is the purpose of the flex-grow property?
o a) Specifies the initial size of a flex container
o b) Controls the growth factor of a flex item
o c) Sets the flexibility of an element
o d) Determines the size of a flex item relative to other items
o Answer: b
• What is the purpose of the HTML placeholder attribute in the <input> tag?
o a) Sets the initial value of the input field
o b) Defines a hint to the user about the expected value of the input
o c) Controls the font style of the input text
o d) Specifies the maximum length of the input field
o Answer: b
• Which CSS property is used to create rounded corners?
o a) border-radius
o b) corner-radius
o c) curve-radius
o d) box-radius
o Answer: a
• In HTML, what is the purpose of the <abbr> element?
o a) Defines an abbreviation or acronym
o b) Creates a hyperlink
o c) Specifies the alignment of text
o d) Defines a block of code
o Answer: a
• What is the purpose of the CSS transform property?
o a) Changes the position of an element
o b) Applies a 3D transformation to an element
o c) Rotates an element
o d) All of the above
o Answer: d
• In HTML, which attribute is used to provide additional information about an
element, such as a tooltip?
o a) info
o b) tooltip
o c) title
o d) description
o Answer: c
• What is the purpose of the CSS transition-timing-function property?
o a) Sets the duration of a transition
o b) Specifies the starting point of a transition
o c) Controls the timing function of a transition
o d) Defines the easing function of a transition
o Answer: d
• Which HTML tag is used for creating a radio button?
o a) <radio>
o b) <input type="radio">
o c) <option>
o d) <input type="option">
o Answer: b
• In CSS, what is the purpose of the text-transform property?
o a) Transforms the background color of text
o b) Transforms the text size
o c) Controls the transformation of text content
o d) Transforms the text case
o Answer: d
• What is the purpose of the HTML disabled attribute in form elements?
o a) Disables the autofocus for the input element
o b) Disables the input element
o c) Specifies the default value for the input element
o d) Disables the required attribute for the input element
o Answer: b
• Which CSS property is used to set the style of the list item marker (bullet or
number)?
o a) list-style-type
o b) marker-style
o c) item-style
o d) list-marker
o Answer: a
• What is the purpose of the HTML accesskey attribute?
o a) Sets the shortcut key for an element
o b) Specifies the access level of an element
o c) Defines the hyperlink key
o d) Controls the access to the document
o Answer: a
• In CSS, what is the purpose of the background-size property?
o a) Controls the background color of an element
o b) Sets the size of the background image
o c) Specifies the background position
o d) Defines the background attachment
o Answer: b
• What is the purpose of the HTML target="_blank" attribute in the <a> tag?
o a) Opens the link in a new window or tab
o b) Sets the target audience for the link
o c) Targets the link to a specific frame
o d) Specifies the link's accessibility
o Answer: a
• Which HTML tag is used for creating a horizontal rule?
o a) <hr>
o b) <line>
o c) <rule>
o d) <horizontal>
o Answer: a
• In CSS, what does the display: flex; property do?
o a) Enables the flex container for the element
o b) Displays the element as an inline element
o c) Controls the display of the element
o d) Sets the element to be hidden
o Answer: a
• What is the purpose of the HTML required attribute in form elements?
o a) Specifies that the input field must be filled out before submitting the form
o b) Sets the default value for the input element
o c) Defines the maximum length of the input field
o d) Specifies the required option for the form
o Answer: a
• Which CSS property is used to create a responsive design by allowing elements
to shrink or grow based on the available space?
o a) responsiveness
o b) flex-grow
o c) responsive-layout
o d) media-query
o Answer: b
• In HTML, what does the <datalist> element provide?
o a) A list of data items for autocomplete suggestions
o b) A list of data sources for an external database
o c) A list of datatypes for form validation
o d) A list of data attributes for metadata
o Answer: a
• What is the purpose of the CSS :nth-child() pseudo-class?
o a) Selects elements based on their position within a parent
o b) Selects elements with a specific class
o c) Targets the first child element
o d) Applies styles to all child elements
o Answer: a
• Which HTML tag is used for creating a hyperlink that links to an email
address?
o a) <email>
o b) <link>
o c) <a>
o d) <mail>
o Answer: c
• In CSS, what is the purpose of the word-wrap property?
o a) Controls the word spacing in text
o b) Wraps long words to the next line to prevent overflow
o c) Specifies the word count in a paragraph
o d) Sets the word alignment in a container
o Answer: b
• What does the acronym CDN stand for in web development?
o a) Central Development Network
o b) Content Delivery Network
o c) Code Development Network
o d) Cached Data Network
o Answer: b
• Which HTML tag is used for creating an unordered list?
o a) <ol>
o b) <ul>
o c) <li>
o d) <list>
o Answer: b
• In CSS, what does the object-fit property do?
o a) Adjusts the size of the object
o b) Controls the positioning of the object within its container
o c) Defines the object's color
o d) Applies a filter to the object
o Answer: b
• What is the purpose of the HTML srcset attribute in the <img> tag?
o a) Sets the source of the image
o b) Specifies the size of the image
o c) Defines a list of possible image sources
o d) Adds a shadow to the image
o Answer: c
• Which CSS property is used to create a sticky element that remains fixed
during scrolling?
o a) position: fixed;
o b) position: sticky;
o c) position: absolute;
o d) position: relative;
o Answer: b
• In HTML, what is the purpose of the <cite> element?
o a) Represents a citation or reference to a creative work
o b) Creates a hyperlink
o c) Defines a block of code
o d) Specifies the citation style for a document
o Answer: a
• What is the purpose of the CSS currentColor keyword?
o a) Sets the current font color
o b) Specifies the color of the current element
o c) Defines the current font size
o d) Controls the background color of the current element
o Answer: b
• Which HTML tag is used for creating a range input slider?
o a) <slider>
o b) <input type="range">
o c) <range>
o d) <input type="slider">
o Answer: b
• What is the purpose of the colspan attribute in HTML tables?
o a) Sets the color of a table cell
o b) Specifies the number of columns a cell should span
o c) Defines the border style of a table
o d) Indicates the type of content in a cell
o Answer: b
• How do you apply CSS styles to a specific table in HTML?
o a) Using the <table-style> tag
o b) Applying styles directly to <tr> elements
o c) Using the <style> tag within the <table> element
o d) Assigning a class or ID to the <table> element
o Answer: d
• What does the CSS property border-collapse control in tables?
o a) The spacing between table cells
o b) The visibility of table borders
o c) The collapsing of table borders
o d) The alignment of table content
o Answer: c
• How can you create a hover effect on table rows using CSS?
o a) Applying :hover to <td> elements
o b) Using the hover class on the table
o c) Applying :hover to <tr> elements
o d) Adding a hover attribute to the <table> tag
o Answer: c
• In HTML tables, what does the rowspan attribute determine?
o a) The color of a table row
o b) The height of a table row
o c) The number of rows a cell should span
o d) The content of a table row
o Answer: c
Forms:
• What is the purpose of the HTML action attribute in a form tag?
o a) Defines the form's action when a button is clicked
o b) Specifies the URL where the form data should be submitted
o c) Sets the form's method to either get or post
o d) Controls the alignment of form elements
o Answer: b
• In HTML forms, what does the enctype attribute define?
o a) The type of encoding used for form data
o b) The alignment of form controls
o c) The encryption level of form data
o d) The type of input expected in the form
o Answer: a
• Which HTML element is used for creating a text input field in a form?
o a) <text>
o b) <input type="text">
o c) <textbox>
o d) <textfield>
o Answer: b
• What is the purpose of the HTML <textarea> element in a form?
o a) Creates a text input field
o b) Defines a dropdown box
o c) Allows multiline text input
o d) Specifies a password input field
o Answer: c
• In HTML forms, what does the method attribute define?
o a) The form's width
o b) The type of data submission (get or post)
o c) The form's action URL
o d) The form's encoding type
o Answer: b
• Which HTML tag is used for creating a checkbox in a form?
o a) <check>
o b) <input type="checkbox">
o c) <box>
o d) <checkbox>
o Answer: b
• What is the purpose of the HTML placeholder attribute in form inputs?
o a) Specifies a default value for the input
o b) Defines a hint for expected input
o c) Sets the input field's width
o d) Controls the font style of the input text
o Answer: b
• Which HTML element is used for creating a dropdown list?
o a) <dropdown>
o b) <list>
o c) <select>
o d) <options>
o Answer: c
• What is the purpose of the HTML required attribute in form elements?
o a) Specifies the default value for the input element
o b) Sets the maximum length of the input field
o c) Requires that the input field must be filled out before submitting the form
o d) Controls the form's accessibility
o Answer: c
• In HTML forms, what does the autocomplete attribute control?
o a) Autocomplete options for the form
o b) The form's action URL
o c) The input field's width
o d) The form's encoding type
o Answer: a
UNIT 5 MCQ
What is the correct way to include an external JavaScript file in an HTML document?
a. <script src="script.js"></script>
b. <include src="script.js">
c. <javascript href="script.js"></javascript>
Answer: a
a. variable x;
b. var x;
c. x = variable;
d. declare x;
Answer: b
a. Assignment
c. Less than
Answer: b
Answer: b
Answer: b
a. myVar
b. 2ndVar
c. _variable
d. $price
Answer: b
Answer: b
a. /* This is a comment */
c. # This is a comment
d. // This is a comment
Answer: d
Answer: a
Answer: c
How can you define a function in JavaScript?
a. function = myFunction() {}
b. define myFunction() {}
c. function myFunction() {}
d. create myFunction() {}
Answer: c
Answer: c
a. onInput
b. onClick
c. onChange
Answer: d
Answer: c
Answer: b
a. +
b. -
c. *
d. /
Answer: a
What is the correct way to write a comment that spans multiple lines in JavaScript?
a. /* This is a comment */
c. # This is a comment
d. // This is a comment
Answer: a
a. parseInt("42")
b. convertToInt("42")
c. strToNum("42")
d. toInteger("42")
Answer: a
d. An error is thrown.
Answer: c
b. To skip the rest of the code in the loop and move to the next iteration
Answer: b
a. constant x = 10;
b. const x = 10;
c. let x = 10;
d. var x = 10;
Answer: b
Answer: a
a. 0
b. null
c. false
Answer: d
Answer: b
a. event.preventDefault();
b. form.preventSubmit();
c. form.cancelSubmit();
d. event.cancelSubmission();
Answer: a
Answer: a
a. push()
b. add()
c. append()
d. insert()
Answer: a
a. Math.round()
b. Math.floor()
c. Math.ceil()
d. Math.random()
Answer: a
Answer: a
Answer: b
a. str.lowerCase()
b. toLowerCase(str)
c. str.toLower()
d. str.toLowerCase()
Answer: d
b. It stands for "Not a Number" and is used to indicate an undefined or unrepresentable value
Answer: b
Answer: a
How can you dynamically change the content of an HTML element using JavaScript?
Answer: b
Answer: a
How do you remove the first element from an array in JavaScript?
a. array.delete(0);
b. array.shift();
c. array.remove(0);
d. array.splice(0, 1);
Answer: b
Answer: b
a. if (variable == undefined)
c. if (undefined(variable))
d. if (isUndefined(variable))
Answer: b
Answer: a
How do you access the value of an input field in JavaScript?
a. document.inputValue('myInput')
b. document.getElement('myInput').value
c. document.getElementById('myInput').getValue()
d. document.getElementById('myInput').value
Answer: d
Answer: b
a. Number.isInteger()
b. isInt()
c. Math.isInteger()
Answer: a
Answer: a
Answer: d
b. To prevent the default action associated with an event from being triggered
Answer: c
a. String(number)
b. number.toString()
c. "" + number
Answer: d
a. /[a-z]/
b. regex("[a-z]")
c. RegExp("[a-z]")
Answer: a
Answer: b
a. typeOf variable
b. typeof variable
c. type(variable)
d. variable.type()
Answer: b
Answer: b
Answer: a
a. str.toArray()
b. Array.from(str)
c. str.split('')
Answer: c
Answer: b
a. element.checkClass('myClass')
b. element.contains('myClass')
c. element.hasClass('myClass')
d. element.isClass('myClass')
Answer: b
Answer: c
How do you create a new date object representing the current date and time in JavaScript?
a. new Date()
b. new Date().now()
c. Date.current()
d. createDate()
Answer: a
Answer: b
a. element.removeAttr('attributeName')
b. element.removeAttribute('attributeName')
c. element.deleteAttr('attributeName')
d. element.remove('attributeName')
Answer: b
Answer: a
a. array.includes(value)
b. array.contains(value)
c. array.hasValue(value)
d. array.indexOf(value) !== -1
Answer: a
Answer: b
a. toUpperCase(str)
b. str.toUpper()
c. str.toUpperCase()
d. convertToUpper(str)
Answer: c
Answer: b
a. array.len()
b. array.length
c. length(array)
d. len(array)
Answer: b
Answer: a
Answer: b
a. isArray(variable)
b. variable.isArray()
c. Array.check(variable)
d. variable.isTypeOf(Array)
Answer: a
a. To create a new array with the results of calling a provided function on every element in the array
Answer: a
How do you declare a function expression in JavaScript?
a. function myFunction() {}
d. Both b and c
Answer: d
Answer: b
a. object1 == object2
b. object1.equals(object2)
c. Object.equals(object1, object2)
Answer: d
Answer: b
How do you round a number down to the nearest integer in JavaScript?
a. Math.floor()
b. Math.round()
c. Math.ceil()
d. Math.trunc()
Answer: a
Answer: a
Answer: b
How do you create a new array by applying a function to each element of an existing array in JavaScript?
a. map()
b. filter()
c. reduce()
d. forEach()
Answer: a
Answer: a
a. isNaN(number)
b. number.isNaN()
c. isNotANumber(number)
Answer: a
Answer: b
How can you create a new date object representing a specific date in JavaScript?
a. new Date('2023-01-01')
b. new Date(2023, 0, 1)
Answer: d
How can you include an external JavaScript file in the <head> section of an HTML document?
a. <script src="script.js"></script>
b. <head src="script.js"></head>
d. <js src="script.js"></js>
Answer: a
c. To exit a function
Answer: a
Which loop executes the code block at least once, even if the condition is false?
a. while
b. for
c. do...while
d. foreach
Answer: c
a. variable x;
b. x = variable;
c. var x;
d. declare x;
Answer: c
a. input()
b. prompt()
c. getInput()
d. read()
Answer: b
Answer: c
Answer: b
a. array.getFirst()
b. array[0]
c. array.first
d. first(array)
Answer: b
d. If a variable is an integer
Answer: a
Answer: c
Answer: b
a. constant x = 10;
b. const x = 10;
c. let x = 10;
d. var x = 10;
Answer: b
Answer: b
a. str.toUpper()
b. str.toUpperCase()
c. toUpperCase(str)
d. convertToUpper(str)
Answer: b
What is the correct way to write a comment that spans multiple lines in JavaScript?
a. /* This is a comment */
c. # This is a comment
d. // This is a comment
Answer: a
Answer: b
a. Math.round(
b. Math.floor()
c. Math.ceil()
d. Math.random()
Answer: a
Answer: a
Answer: b
a. array.delete(0);
b. array.shift();
c. array.remove(0);
d. array.splice(-1, 1);
Answer: b
a. array.includes(value)
b. array.contains(value)
c. array.hasValue(value)
d. array.indexOf(value) !== -1
Answer: a
Answer: b
a. str.toLower()
b. toLowerCase(str)
c. str.toLowerCase()
d. str.lowerCase()
Answer: c
d. If a variable is an integer
Answer: a
In JavaScript, what is the purpose of the this keyword?
Answer: c
Answer: c
How can you include an external JavaScript file in the <head> section of an HTML document?
a. <script src="script.js"></script>
b. <head src="script.js"></head>
d. <js src="script.js"></js>
Answer: a
Answer: b
How do you prompt the user for input in JavaScript?
a. input()
b. prompt()
c. getInput()
d. read()
Answer: b
Answer: b
a. array.getFirst()
b. array[0]
c. array.first
d. first(array)
Answer: b
Answer: b
How can you declare a constant variable in JavaScript?
a. constant x = 10;
b. const x = 10;
c. let x = 10;
d. var x = 10;
Answer: b
What is the correct way to write a comment that spans multiple lines in JavaScript?
a. /* This is a comment */
c. # This is a comment
d. // This is a comment
Answer: a
Answer: b
a. Math.round()
b. Math.floor()
c. Math.ceil()
d. Math.trunc()
Answer: a
Answer: a
Answer: b
a. array.delete(0);
b. array.shift();
c. array.remove(0);
d. array.splice(-1, 1);
Answer: b
Answer: b
b. array.contains(value)
c. array.hasValue(value)
d. array.indexOf(value) !== -1
Answer: a
Answer: b
a. str.toLower()
b. toLowerCase(str)
c. str.toLowerCase()
d. str.lowerCase()
Answer: c
d. If a variable is an integer
Answer: a
Answer: c
Answer: c
How can you include an external JavaScript file in the <head> section of an HTML document?
a. <script src="script.js"></script>
b. <head src="script.js"></head>
d. <js src="script.js"></js>
Answer: a
Answer: b
a. input()
b. prompt()
c. getInput()
d. read()
Answer: b
a. var x = 10;
b. let x = 10;
c. const x = 10;
d. global x = 10;
Answer: a
c. To concatenate strings
Answer: b
Answer: b
a. /* This is a comment */
d. // This is a comment
Answer: d
Answer: b
a. Not a Number
c. Non-Applicable Number
d. Numeric Array
Answer: a
How can you prevent the default behavior of an HTML form submission using JavaScript?
a. event.default();
b. event.stop();
c. event.preventDefault();
d. event.halt();
Answer: c
Answer: b
Answer: a
Answer: b
UNIT 6 MCQ
2. Which of the following is not a JavaScript data type? a) Number b) String c) Boolean
d) Float
Answer: d) Float
3. How do you declare a variable in JavaScript? a) var x; b) x = var; c) variable x; d) x :=
Answer: a) var x;
4. What does the === operator do in JavaScript? a) Checks for equality without type
coercion b) Checks for equality with type coercion c) Assigns a value d) Checks for
inequality without type coercion
5. What is the purpose of the setTimeout function in JavaScript? a) Pauses the execution
of the script b) Sets a delay before executing a function c) Executes a function immediately
d) Sets an interval for executing a function repeatedly
Answer: b) function
7. What does the this keyword refer to in JavaScript? a) The current function b) The
global object c) The object that is executing the current function d) The parent function
8. How do you comment a single line in JavaScript? a) <!-- Comment --> b) /* Comment
*/ c) // Comment d) -- Comment --
Answer: c) // Comment
10. Which of the following is a falsy value in JavaScript? a) 0 b) " " c) true d) "hello"
Answer: a) 0
DOM Concepts:
11. What does DOM stand for? a) Document Object Model b) Data Object Model c)
Document Order Model d) Document Offset Model
Answer: b) getElementById
13. How do you create a new HTML element using JavaScript? a) createNode b)
createElement c) newElement d) makeElement
Answer: b) createElement
14. What property is used to change the content of an HTML element in JavaScript? a)
innerText b) contentText c) textContent d) innerHTML
Answer: d) innerHTML
15. How do you add a class to an HTML element using JavaScript? a) addClass b)
appendClass c) addAttribute d) classList.add
Answer: d) classList.add
16. Which method is used to remove a class from an HTML element in JavaScript? a)
removeClass b) deleteClass c) classList.remove d) detachClass
Answer: c) classList.remove
17. What is the purpose of the setAttribute method in JavaScript? a) Sets the style of an
element b) Adds a new attribute to an element c) Removes an attribute from an element d)
Retrieves the value of an attribute
18. Which property is used to change the CSS style of an HTML element in JavaScript?
a) style b) css c) layout d) design
Answer: a) style
19. What does the querySelector method do in JavaScript? a) Selects the first element
that matches a CSS selector b) Selects all elements that match a CSS selector c) Selects the
last element that matches a CSS selector d) Selects elements based on their IDs
20. Which method is used to add an event listener to an HTML element in JavaScript?
a) addEventListener b) attachEvent c) addEvent d) eventListener
Answer: a) addEventListener
21. What is the purpose of the preventDefault method in an event listener? a) Stops the
event from propagating to parent elements b) Prevents the default action associated with
the event c) Delays the execution of the event handler d) Stops the event from bubbling up
the DOM tree
22. Which event type is triggered when a user clicks an HTML element? a) click b)
mouseover c) keypress d) submit
Answer: a) click
24. What does the stopPropagation method do in an event listener? a) Stops the event
from propagating to parent elements b) Prevents the default action associated with the
event c) Delays the execution of the event handler d) Stops the event from bubbling up the
DOM tree
25. How do you access the target element in an event listener? a) event.element b)
event.target c) event.srcElement d) event.destination
Answer: b) event.target
26. What is the purpose of the typeof operator in JavaScript? a) Returns the type of a
variable or expression b) Checks if a variable is defined c) Converts a variable to a boolean
d) Converts a variable to a string
28. What does the NaN value represent in JavaScript? a) Not a Number b) Null and None
c) Negative Absolute Number d) No Assignment
Answer: a) toUpperCase()
30. What is the purpose of the JSON.stringify function in JavaScript? a) Parses a JSON
string b) Converts a JavaScript object to a JSON string c) Converts a JSON string to a
JavaScript object d) Checks if a string is in JSON format
DOM Concepts:
31. Which property is used to access the parent node of an element in JavaScript? a)
parentNode b) parentElement c) parent d) parentDiv
Answer: a) parentNode
32. What is the purpose of the appendChild method in JavaScript? a) Appends an element
to the end of the parent's child nodes b) Removes the last child node of an element c)
Creates a new child node for an element d) Appends an element to the beginning of the
parent's child nodes
Answer: c) removeChild()
34. What does the innerHTML property do in JavaScript? a) Returns the content of an
element as HTML b) Sets the text content of an element c) Returns the text content of an
element d) Sets the HTML content of an element
35. What is the purpose of the cloneNode method in JavaScript? a) Creates a duplicate of
an element b) Removes a node from the DOM c) Clones the parent node of an element d)
Copies the attributes of an element
36. Which method is used to check if an element has a particular class in JavaScript?
a) hasClass b) containsClass c) includesClass d) classList.contains
Answer: d) classList.contains
37. What is the purpose of the getAttribute method in JavaScript? a) Retrieves the value
of an attribute b) Sets the value of an attribute c) Checks if an attribute exists d) Removes
an attribute from an element
38. How do you change the source (src) attribute of an image element in JavaScript?
a) image.src = "new-source.jpg"; b) image.changeSrc("new-source.jpg"); c)
image.setAttribute("src", "new-source.jpg"); d) image.updateSource("new-source.jpg");
39. What is the purpose of the firstChild property in JavaScript? a) Returns the first
child node of an element b) Returns the last child node of an element c) Returns the parent
node of an element d) Returns the sibling node before an element
Answer: a) inputElement.focus()
DOM HTML:
41. How do you create a line break (line break element) in HTML? a) <line> b) <br> c)
<lb> d) <break>
Answer: b) <br>
42. Which HTML element is used to define a hyperlink? a) <link> b) <hyperlink> c) <a>
d) <url>
Answer: c) <a>
43. What is the purpose of the alt attribute in the <img> element in HTML? a) Specifies
the image source b) Defines alternative text for the image c) Sets the image width d)
Specifies the image alignment
44. Which HTML element is used to define an unordered list? a) <list> b) <ol> c) <ul>
d) <li>
Answer: c) <ul>
45. How do you create a table in HTML? a) <table> b) <tr> c) <td> d) All of the above
DOM CSS:
46. What is the purpose of the display property in CSS? a) Sets the width of an element
b) Defines the type of box an element generates c) Specifies the margin of an element d)
Sets the background color of an element
47. How do you set the font size of an element in CSS? a) font-size b) text-size c) size-
font d) font-style
Answer: a) font-size
48. What does the margin: 10px 20px; CSS rule do? a) Sets the top margin to 10 pixels and
the right margin to 20 pixels b) Sets the margin to 10 pixels for all sides c) Sets the top and
bottom margins to 10 pixels and the left and right margins to 20 pixels d) Sets the margin
to 20 pixels for all sides
Answer: c) Sets the top and bottom margins to 10 pixels and the left and right
margins to 20 pixels
49. How do you center an element horizontally in CSS? a) text-align: center; b) margin:
auto; c) align: center; d) center: true;
50. What is the purpose of the float property in CSS? a) Sets the alignment of text b)
Clears the floated elements c) Creates a floating element d) Specifies the positioning of an
element
DOM Events:
51. Which event type is triggered when a user presses a key on the keyboard? a)
keydown b) keypress c) keyup d) keyboard
Answer: a) keydown
53. How do you attach multiple event listeners to the same element in JavaScript? a)
addEventListeners b) addEvent c) addEventListenerAll d) addListener
Answer: a) addEventListeners
54. Which method is used to remove an event listener from an HTML element in
JavaScript? a) removeEvent b) removeEventListener c) deleteEventListener d)
removeListener
Answer: b) removeEventListener
55. What does the mouseover event type do in JavaScript? a) Triggered when the mouse
pointer enters an element b) Triggered when the mouse pointer leaves an element c)
Triggered when a key is pressed d) Triggered when a key is released
56. Which event type is triggered when an HTML form is submitted? a) submitForm b)
formSubmit c) submit d) formSubmitted
Answer: c) submit
58. Which property is used to access the key that was pressed in a keypress event? a)
key b) keyCode c) charCode d) pressKey
Answer: a) key
59. How do you check if the Ctrl key is pressed in a keyboard event in JavaScript? a)
event.ctrlKey b) event.key === "Ctrl" c) event.isCtrlPressed d) event.hasCtrlKey
Answer: a) event.ctrlKey
60. What does the focus event type do in JavaScript? a) Triggered when an element
gains focus b) Triggered when an element loses focus c) Triggered when a key is pressed d)
Triggered when a key is released
61. What is the purpose of the map function in JavaScript? a) Applies a function to each
element in an array and returns a new array b) Joins two arrays into a single array c)
Removes elements from an array based on a condition d) Finds the maximum value in an
array
Answer: a) Applies a function to each element in an array and returns a new array
62. How do you check if a variable is an array in JavaScript? a) isArray(variable) b)
isTypeOf(variable, "array") c) variable.isArray() d) typeOf(variable) === "array"
Answer: a) isArray(variable)
63. What is the purpose of the filter function in JavaScript? a) Creates a new array
with the results of a provided function b) Removes elements from an array based on a
condition c) Sorts the elements of an array d) Checks if all elements in an array pass a test
64. How do you declare a constant variable in JavaScript? a) const x = 10; b) let x = 10;
c) var x = 10; d) constant x = 10;
65. What is the purpose of the splice method in JavaScript? a) Adds or removes
elements from an array b) Concatenates two arrays c) Reverses the elements of an array d)
Finds the index of a specified element in an array
DOM Concepts:
66. How do you create a text node in the DOM using JavaScript? a) createTextElement
b) newTextElement c) document.createTextNode d) textNode.create
Answer: c) document.createTextNode
67. What does the event.currentTarget property return in an event listener? a) Returns
the target element of the event b) Returns the current element being processed in the event
propagation c) Returns the event type d) Returns the parent element of the event target
Answer: b) Returns the current element being processed in the event propagation
Answer: a) element.hasAttribute("attributeName")
69. What is the purpose of the classList.toggle method in JavaScript? a) Adds a class to
an element b) Removes a class from an element c) Toggles between adding and removing a
class from an element d) Checks if an element has a specific class
70. How do you set the value of a form input field using JavaScript? a) inputField.value
= "new value"; b) setInputValue(inputField, "new value"); c) inputField.setValue("new
value"); d) setFormValue("new value", inputField)