UNIT 1-Solved Question Bank
UNIT 1-Solved Question Bank
IV Semester BCA
2023
2023
Submitted By:
U05DG21S0159
U05DG21S0162
U05DG21S0164
U05DG21S0167
U05DG21S0171
U05DG21S0172
U05DG21S0174
U05DG21S0178
U05DG21S0179
U05DG21S0191
U05DG21S0195
U05DG21S0196
U05DG21S0199
U05DG21S0207
U05DG21S0211
Submitted To:
Chaithra Ma’am
Dept. of CS
2 MARKS QUESTIONS
Dr. G. Shankar Govt. Women’s First Grade College & PG Study Centre
Ajjarkadu, Udupi
Solved Question Bank
2 MARKS QUESTIONS
1. Opening tag: It is the starting point of an HTML element and is enclosed in angle brackets. The tagname
represents the type of element you want to define.
2. Attributes: They provide additional information about the HTML element. Attributes are placed within
the opening tag and consist of a name-value pair, separated by an equals sign (=). Attribute values are
usually enclosed in double quotes.
3. Content: It is the actual text or other HTML elements that appear within the element. The content is
placed between the opening and closing tags.
4. Closing tag: It marks the end of an HTML element and is similar to the opening tag, except that it includes
a forward slash (/) before the tagname.
Salwa Sulthana
II BCA
Solved Question Bank
3. What is the use of <audio> tag? Write its important attributes with their purpose.
The `<audio>` tag is an HTML element used to embed audio content, such as music or sound clips,
into a web page. It allows you to play audio files directly within the browser without requiring any external
media players.
4. What is the use of <video> tag? Write its important attributes with their purpose.
The `<video>` tag is an HTML element used to embed videos or movies on a web page. It allows
you to include video content and control its playback using various attributes.
Here are some important attributes commonly used with the `<video>` tag and their purposes:
1. `src`: Specifies the URL or file path of the video source.
3. `width` and `height`: Sets the dimensions of the video player on the webpage.
7. What is the use of target attribute of <a> element? List the possible values.
Salwa Sulthana
II BCA
Solved Question Bank
8. Write a note on HTML5 audio tag with its attributes.
The HTML5 <audio> tag is a markup element introduced in HTML5 to easily embed and control
audio content on web pages. It allows you to include audio files, such as music, sound effects, or podcasts,
directly into your HTML documents.
9. What does <br/> tag do? Whats the use of its clear attribute?
When the <br/> tag is used, it creates a line break, causing the text or content that follows it to
appear on the next line.It is commonly used when you want to separate text into multiple lines without
creating a new paragraph or adding additional spacing.
The "clear" attribute is used with the <br> tag (without the slash) and specifies how floating elements should
behave in relation to the line break.
10. What is the purpose of <div> tag? What’s the use of its nowrap attribute.
The purpose of the <div> tag is to group and organize various elements, such as text, images, forms,
or other HTML elements, allowing you to apply styles or manipulate them as a single unit.
The nowrap attribute is commonly used with the <td> (table data) or <th> (table header) elements within
an HTML table. When applied to these elements, the nowrap attribute prevents the contents of the table cell
from wrapping to the next line, keeping the content in a single line instead.
16. What is the use of <label> tag? What is the purpose of it’s for attribute?
The <label> tag in HTML is used to associate a text label with an input element. It helps improve
the accessibility and usability of forms on web pages.
The for attribute of the <label> tag is used to specify which form element the label is associated with. It
takes the id attribute value of the related input element as its value.
18. What is the use of cellpadding and cellspacing attributes in <table> element?
The `cellpadding` and `cellspacing` attributes are used in the `<table>` element to control the
spacing and padding between cells in an HTML table.
1. `cellpadding`: This attribute specifies the amount of space, in pixels, to be added inside each cell of the
table.
2. `cellspacing`: This attribute specifies the amount of space, in pixels, to be added between adjacent cells
in the table.
19. What is the purpose colspan and rowspan attributes of <td> tag?
The `colspan` and `rowspan` attributes are used in HTML `<td>` (table cell) tags to control the
spanning behavior of cells within an HTML table.
20. What is the purpose of <th> tag? List any four attributes.
The <th> tag defines a header cell in an HTML table. An HTML table has two kinds of cells: Header
cells - contains header information (created with the <th> element) Data cells - contains data (created with
the <td> element.
Salwa Sulthana
II BCA
Solved Question Bank
22. What is the use of <ul> tag? What is the purpose of its type attribute?
The `<ul>` tag in HTML is used to create an unordered list. "UL" stands for "unordered list." It is
commonly used to represent a list of items that do not have a particular order or sequence.
The purpose of the `type` attribute in the `<ul>` tag is to specify the type of bullet or marker to be used for
each list item. By default, the bullet points used in unordered lists are usually solid circles.
23. What are the ways to include JavaScript in a webpage? Give example code for each.
There are following three ways in which users can add JavaScript to HTML pages.
• Embedding code.
<!DOCTYPE html >
<html>
<head>
<title> page title</title>
<script>
document.write("Welcome to Javatpoint");
</script>
</head>
<body>
<p>Inthis example we saw how to add JavaScript in the head section </p>
</body>
</html>
Salwa Sulthana
II BCA
Solved Question Bank
• Inline code.
<!DOCTYPE html >
<html>
<head>
<title> page title</title>
</head>
<body>
<p>
<a href="#" onClick="alert('Welcome !');">Click Me</a>
</p>
<p> in this example we saw how to use inline JavaScript or directly in an HTML tag. </p>
</body>
</html>
• External file.
<html>
<head>
<meta charset="utf-8">
<title>Including a External JavaScript File</title>
</head>
<body>
<form>
<input type="button" value="Result" onclick="display()"/>
</form>
<script src="hello.js">
</script>
</body>
</html>
Create a separate file:
function display() {
alert("Hello World!");
}
Salwa Sulthana
II BCA
Solved Question Bank
27. What are the uses of === and !== operators of JavaScript.
Salwa Sulthana
II BCA
Solved Question Bank
28. List any four special operators of JavaScript with their purpose.
29. Write the purpose of for in and for each in loops of JavaScript.
Salwa Sulthana
II BCA
Solved Question Bank
32. What is object initializers? Provide proper example.
An object initializer is a comma-delimited list of zero or more pairs of property names and
associated values of an object, enclosed in curly braces ( {} ).
Example:
const object1 = { a: 'foo', b: 42, c: {} };
console.log(object1.a);
// Expected output: "foo"
const a = 'foo';
const b = 42;
const c = {};
const object2 = { a: a, b: b, c: c };
console.log(object2.b);
// Expected output: 42
const object3 = { a, b, c };
console.log(object3.a);
// Expected output: "foo"
DESCRIPTIVE QUESTIONS
1.List and explain some of the most commonly used (X)HTML elements. (6)
Some commonly used (X)HTML elements along with their explanations:
1. `<html>`: This element represents the root of an HTML document and wraps around all other elements
on the page.
2. `<head>`: This element contains meta-information about the webpage, such as the title, character
encoding, linked stylesheets, and scripts.
3. `<title>`: This element specifies the title of the webpage, which appears in the browser's title bar or tab.
4. `<body>`: This element contains the visible content of the webpage, including text, images, links, and
other elements.
5. `<h1>` to `<h6>`: These elements represent headings of different levels, with `<h1>` being the highest
level (main heading) and `<h6>` being the lowest level (subheading).
6. `<p>`: This element defines a paragraph of text. It is commonly used to structure and separate blocks of
text.
Salwa Sulthana
II BCA
Solved Question Bank
2. Explain HTML AND XHTML DTD specifications with example. (6)
XHTML (Extensible Hypertext Markup Language) is a markup language that combines the
flexibility of HTML (Hypertext Markup Language) with the strictness of XML (eXtensible Markup
Language). It is designed to be compatible with both HTML and XML parsers, making it an ideal choice
for creating web pages that adhere to well-defined standards.
XHTML DTD (Document Type Definition) specifications define the structure and rules that XHTML
documents must follow. The DTD specifies the elements, attributes, and entities allowed in an XHTML
document, as well as their hierarchy and relationship.
example:
xml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3. Explain the HTML document structure with the help of a diagram. (4)
Salwa Sulthana
II BCA
Solved Question Bank
Salwa Sulthana
II BCA
Solved Question Bank
2. Elements: (X)HTML documents are made up of elements, which are defined by tags. Elements can be
either empty (such as `<br>`) or contain content (such as `<p>` for paragraphs). Each element has an
opening tag (`<tag>`) and a closing tag (`</tag>`). Elements can be nested inside each other, forming a
hierarchical structure.
3. Tags and Attributes: Tags define the purpose of an element, while attributes provide additional
information or modify the behavior of an element. Tags and attributes are case-insensitive and should be
written in lowercase. For example, `<img>` is an empty element used to display an image, and it may have
attributes like `src` (source) and `alt` (alternative text).
4. Nesting: Elements can be nested within each other, but they must be properly nested. This means that an
element's closing tag must appear after its opening tag and cannot overlap with other elements.
5. Self-Closing Elements: Some elements are self-closing, meaning they don't require a closing tag. Instead,
they are terminated with a forward slash before the closing angle bracket. For example, `<br>` is used for
line breaks, and `<img>` is used for images.
6. Document Type Declaration (DTD): An (X)HTML document should start with a document type
declaration to specify the version and type of (X)HTML being used.
Salwa Sulthana
II BCA
Solved Question Bank
3. Number Field (`<input type="number">`): This field is used for capturing numeric input. It can restrict
input to numeric values and can include additional attributes like `min`,`max`, and `step` to define
acceptable value ranges and increments. Some browsers also provide a spinner control to increment or
decrement the value.
4. Range Field (`<input type="range">`): This field is used for capturing a value within a specified range.
It renders a slider control that allows users to select a value within the defined range. The current value is
displayed visually on the slider thumb.
5.Date and Time Fields (`<input type="date">`, `<input type="time">`, `<input type="datetime-
local">`):These fields are used for capturing dates, times, or both. The `date` field displays a date picker,
while the `time` field allows users to select a specific time. The `datetime-local` field combines both date
and time selection. Browsers typically provide native UI controls for these fields.
9. What is the use of <a> tag? Mention any 5 element specific attributes of it. (6)
Salwa Sulthana
II BCA
Solved Question Bank
10. Explain the use of <article> element of HTML5 with any five unique attributes. (6)
11. Write a short note on <aside> with any of its 5 unique attributes.(6)
12. Explain any 4/6 unique element specific attributes of <body> tag.(4/6)
Salwa Sulthana
II BCA
Solved Question Bank
13. Explain any 4/6 unique element specific attributes of <button> tag. (4/6)
The `<button>` tag is used to create clickable buttons on a webpage. It has several attributes that
allow you to customize its behavior and appearance. Here are four unique element-specific attributes of the
`<button>` tag:
1. `autofocus`: This attribute specifies that the button should have automatic focus when the page loads. It
is used when you want the button to be selected by default without any user interaction.
2. `disabled`: This attribute indicates that the button should be disabled and cannot be interacted with by
the user. It is commonly used when you want to temporarily prevent users from clicking a button.
3. `form`: This attribute specifies the ID of the form element the button belongs to. It is used when you
want to associate a button with a specific form for submission purposes.
4. `type`: This attribute determines the type of button being created. It can take several values, including
`"submit"`, `"reset"`, and `"button"`. The default value is `"submit"`, which submits the form data. The
`"reset"` type resets the form, and the `"button"` type is a regular button without any special behavior.
14. Explain any 4/6 unique element specific attributes of <font> tag. (4/6)
1. `size`: This attribute allowed you to specify the size of the font. It accepted a numerical value indicating
the size in pixels or a relative value such as "small," "medium," or "large
2. `color`: This attribute allowed you to specify the color of the text. It accepted a color value, such as a
color name or a hexadecimal value.
3. `face`: This attribute allowed you to specify the font face or typeface for the text. It accepted the name
of a font or a comma-separated list of font names in order of preference.
4. `bgcolor`: This attribute allowed you to specify the background color behind the text. It accepted a color
value, such as a color name or a hexadecimal value.
15. What is <form> tag? Write any of its 5 element specific attributes. (6)
The `<form>` tag in HTML is used to create an interactive form on a web page. It acts as a container
for various form elements, such as input fields, checkboxes, radio buttons, buttons, etc. The `<form>` tag
allows users to input data and submit it to the server for further processing.
Here are five commonly used attributes specific to the `<form>` tag:
1.action: This attribute specifies the URL or server-side script to which the form data is submitted when the
form is submitted by the user
2. method: This attribute specifies the HTTP method to be used when submitting the form data. The two
most common methods are "GET" and "POST". "GET" appends the form data to the URL, while "POST"
sends the data in the request body.
3.name: This attribute assigns a unique name to the form. It is useful when multiple forms are present on
the same web page or when referencing the form using JavaScript.
4.target: This attribute specifies where the response from the server should be displayed after form
submission. It can take values like "_blank" (opens in a new window or tab) or "_self" .
Salwa Sulthana
II BCA
Solved Question Bank
5.enctype: This attribute specifies how the form data should be encoded and sent to the server. It is
commonly used when uploading files through a form. The two most common values are "application/x-
www-form-urlencoded" (default) and "multipart/form-data.
16. Write a not <hr> tag with all of its element-specific attributes. (6)
The `<hr>` tag in HTML is a self-closing tag that is used to create a horizontal rule, which is a visual
separator in a web page. The `<hr>` tag does not have any element-specific attributes. However, you can
use global attributes with the `<hr>` tag. Here's an example of an `<hr>` tag with some commonly used
global attributes:
Example:
<hr class="my-hr" id="my-hr-id" style="color: blue;" data-custom-attribute="example">
In this example:
- `class`: Specifies one or more class names for the element. In this case, the class name is "my-hr".
- `id`: Specifies a unique identifier for the element. In this case, the ID is "my-hr-id".
- `style`: Inline CSS style rules to apply to the element. In this case, it sets the color of the horizontal rule
to blue.
- `data-custom-attribute`: A custom data attribute that can be used to store extra information. In this case, it
is set to "example" as a placeholder.
17. Write the four element specific attributes of <html> element with their purpose. (4)
The `<html>` element is the root element of an HTML document and represents the entire
document. It encapsulates all the content within an HTML file. Here are the four element-specific attributes
of the `<html>` element along with their purposes:
1. `lang`: This attribute specifies the primary language of the HTML document. It helps in indicating the
language to be used for parsing and rendering the content. It is essential for accessibility and search engine
optimization, as it enables assistive technologies and search engines to understand the language of the
document.
Example: `<html lang="en">`
2. `dir`: The `dir` attribute defines the text directionality of the document's content. It is used to specify
whether the text should be displayed from left-to-right (default) or right-to-left. This attribute is primarily
used for languages that are written from right to left, such as Arabic or Hebrew.
Example: `<html dir="rtl">`
3. `manifest`: This attribute points to the URL of a document that specifies a web application's cache
manifest file. The cache manifest file defines which resources should be cached by the browser for offline
use. It allows developers to create web applications that can be accessed even when the user is offline.
Example: `<html manifest="example.appcache">`
4. `xmlns`: The `xmlns` attribute defines the XML namespace for the document. It is primarily used for
documents that mix HTML with other XML-based languages or for documents that use custom XML
vocabularies. It helps differentiate the HTML elements from other elements in the document.
Example: `<html xmlns="http://www.w3.org/1999/xhtml">`
Salwa Sulthana
II BCA
Solved Question Bank
18. Explain the <iframe> element with it element specific attributes(any 4/6). (4/6)
The `<iframe>` element in HTML is used to embed another HTML document within the current
document. It creates a window or "frame" in which the content of the embedded document is displayed.
The `<iframe>` element has several attributes that can be used to control its behavior.
Here are six commonly used attributes:
1. `src`: This attribute specifies the URL of the document to be embedded within the `<iframe>`. It can be
a relative or absolute URL.
2. `width` and `height`: These attributes determine the dimensions of the `<iframe>`. You can set the width
and height using pixel values or relative units like percentages.
3. `frameborder`: This attribute specifies whether or not to display a border around the `<iframe>`. If set to
"0", no border will be shown. If set to "1", a border will be displayed.
4. `scrolling`: This attribute controls the display of scrollbars within the `<iframe>`. It can take one of three
values: "auto" (scrollbars are displayed as needed), "yes" (scrollbars are always shown), or "no" (scrollbars
are never displayed).
5. `sandbox`: This attribute provides an extra layer of security by restricting what actions the embedded
document can perform. It can be set to a list of specific values, such as "allow-forms" to enable form
submission or "allow-scripts" to allow JavaScript execution.
6. `allowfullscreen`: This attribute is used when embedding videos or interactive content. If set to "true" or
"1", it allows the embedded document to enter fullscreen mode.
19. Explain <img> tag with its element specific attributes (6)
Salwa Sulthana
II BCA
Solved Question Bank
20. Explain <input> tag with its element specific attributes (6)
The `<input>` tag in HTML is used to create various types of input fields or controls within a web
form. It allows users to enter data or make selections, which can then be submitted to a server for further
processing. The `<input>` tag has several attributes that define its behaviour and appearance.
Here are some of the commonly used attributes:
1. type: This attribute specifies the type of input control to be rendered. The value of this attribute
determines the behaviour and appearance of the input field. Some commonly used types include:
- `text`: Creates a single-line text input field.
- `password`: Creates a password input field where the entered characters are masked.
- `number`: Creates a numeric input field.
- `checkbox`: Creates a checkbox for selecting multiple options.
- `radio`: Creates a radio button for selecting a single option.
- `submit`: Creates a submit button for form submission.
2. name: The `name` attribute assigns a name to the input field, which is used to identify the field when the
form is submitted.
3.value: The `value` attribute sets the initial value of the input field. For example, for a text input field, the
`value` attribute specifies the default text displayed.
4.placeholder: The `placeholder` attribute provides a short hint or example text that is displayed in the input
field before the user enters their own value.
5.required: The `required` attribute specifies that the input field must be filled out before submitting the
form. If this attribute is present, the browser will prevent form submission until the field is completed.
6.disabled: The `disabled` attribute disables the input field, preventing user interaction and making it appear
grayed out.
Salwa Sulthana
II BCA
Solved Question Bank
1. `value`: This attribute is used in ordered lists (`<ol>`) to specify the starting value for the list item. By
default, ordered lists start at 1, but you can set a different starting value using the `value` attribute. For
example: `<ol start="3">`.
2. `type`: This attribute is used in ordered lists (`<ol>`) to specify the type of numbering or bullet style for
the list item. It can take several values such as "1" (decimal numbers), "A" (uppercase letters), "a"
(lowercase letters), "I" (uppercase Roman numerals), or "i" (lowercase Roman numerals). For example:
`<ol type="A">`.
3. `class`: This attribute allows you to specify one or more class names to associate with the list item. It is
commonly used for CSS styling or JavaScript manipulation. For example: `<li class="highlight">`.
4. `id`: This attribute provides a unique identifier for the list item. It can be used for targeting the item with
JavaScript or CSS. For example: `<li id="item1">`.
5. `style`: This attribute allows you to apply inline CSS styles directly to the list item. You can use this
attribute to control the visual appearance of the list item. For example: `<li style="color: red;">`.
6. `dir`: This attribute specifies the directionality of the list item's text. It can have the values "ltr" (left to
right) or "rtl" (right to left). It is primarily used for languages that are written from right to left. For example:
`<li dir="rtl">`.
22. Explain the use of <link> tag with its attributes. (4)
The `<link>` tag is an HTML element that is primarily used to link external resources to an HTML
document. It is commonly used to link CSS stylesheets, icon files, and other external resources that enhance
the presentation and functionality of a web page. The `<link>` tag is placed within the `<head>` section of
an HTML document.
The `<link>` tag has several attributes that define the relationship between the current document and the
linked resource.
Here are some most commonly used attributes:
1. `href`: This attribute specifies the URL (Uniform Resource Locator) of the linked resource. It can be a
relative or absolute URL.
2. `rel`: The "rel" attribute defines the relationship between the current document and the linked resource.
It is used to specify the purpose or type of the linked resource.
3. `type`: The "type" attribute specifies the MIME type of the linked resource. For CSS stylesheets, the
most common value is `text/css`. For icons, it could be `image/png` or `image/jpeg`, depending on the
image format.
4. `media`: This attribute specifies the media type or media query for which the linked resource is intended.
It allows you to define different stylesheets for different devices or screen sizes. For example:
- `media="screen"`: The linked resource is intended for screens.
- `media="print"`: The linked resource is intended for printing.
Salwa Sulthana
II BCA
Solved Question Bank
23. Explain the use of <marquee> tag with 4 of its element specific attributes. (6)
24. What is the use of <ol> ordered list? Explain with attributes. (6)
The HTML `<ol>` (ordered list) element is used to create a numbered list of items. It is a container
element that holds a list of individual list items denoted by the `<li>` (list item) element. The `<ol>` element
specifies that the list items should be displayed in a particular order, typically using numbers.
Here are some attributes commonly used with the `<ol>` element:
1. type: This attribute specifies the type of numbering to be used for the list. The possible values are:
- "1" (default): Numbers (1, 2, 3, ...).
- "A": Uppercase letters (A, B, C, ...).
- "a": Lowercase letters (a, b, c, ...).
- "I": Uppercase Roman numerals (I, II, III, ...).
- "i": Lowercase Roman numerals (i, ii, iii, ...).
2.start: This attribute specifies the starting number for the first list item. By default, it starts from 1, but you
can set a different number.
3.reversed: When this boolean attribute is present, it indicates that the numbering should be displayed in
reverse order, starting from the highest value and decrementing. This is useful for creating countdowns or
rankings.
4.compact: When this boolean attribute is present, it specifies that the spacing between the list items should
be reduced, resulting in a more compact display.
Salwa Sulthana
II BCA
Solved Question Bank
25. Explain what is the use of <script> tag? Explain its 6 element specific attribute. (6)
The `<script>` tag in HTML is used to embed or reference JavaScript code within an HTML document. It
allows you to define and execute scripts on the client-side, enabling dynamic and interactive functionality
on web pages.
Here are six specific attributes commonly used with the `<script>` tag:
1.`src`: This attribute specifies the URL of an external JavaScript file that should be loaded and executed.
2. `type`: This attribute specifies the MIME type of the scripting language being used. The most common
value is `text/javascript`, which indicates JavaScript code.
3. `async`: When present, this attribute indicates that the script should be executed asynchronously. It allows
the script to be downloaded in parallel with the HTML parsing process, and it will execute as soon as it's
available, without blocking the rendering of the page.
4. `defer`: When present, this attribute indicates that the script should be executed after the document has
been parsed. Unlike the `async` attribute, it does not block the rendering of the page. Multiple `defer` scripts
are executed in the order they appear in the HTML.
5. `integrity`: This attribute is used for Subresource Integrity (SRI) checks. It allows you to provide a
cryptographic hash value that ensures the downloaded script hasn't been tampered with. This helps protect
against attacks that modify the script's content during transit.
6. `nonce`: This attribute allows you to provide a cryptographic nonce (number used once) that is used to
enforce a Content Security Policy (CSP). The nonce value must match the value specified in the CSP header
for the script to be executed. It helps prevent the execution of unauthorized scripts.
Salwa Sulthana
II BCA
Solved Question Bank
27. Explain <style> tag with its element-specific attributes. (6)
The `<style>` tag is an HTML element that is used to define styles for HTML documents. It is
typically placed within the `<head>` section of an HTML file. The styles defined within the `<style>` tag
can be applied to various elements in the HTML document using element-specific attributes.
The `<style>` tag allows you to define CSS (Cascading Style Sheets) rules that determine the visual
presentation of HTML elements. These rules consist of selectors, which target specific elements, and
declarations, which specify the styling properties for those elements.
1.Element selector: You can target a specific HTML element using its tag name. For example, to style all
`<h1>` headings, you can use the following selector:
h1 {
/* CSS declarations for h1 elements */
}
2. Class selector: You can assign a class attribute to HTML elements and use the class selector to target
those elements. For example, to style all elements with the class "my-class", you can use the following
selector:
.my-class {
/* CSS declarations for elements with the class "my-class" */
}
3.ID selector: You can assign an id attribute to a specific HTML element and use the ID selector to target
that element. IDs should be unique within the document. For example, to style an element with the id "my-
id", you can use the following selector:
#my-id {
/* CSS declarations for the element with the ID "my-id" */
}
28. Explain <table> tag with its any five element specific attributes. (6)
The `<table>` tag is an HTML element used to create tables on a web page. It serves as a container
for other table-related elements such as `<tr>` (table row), `<th>` (table header cell), and `<td>` (table data
cell). Here are five specific attributes commonly used with the `<table>` tag:
1. `border`: This attribute specifies the width of the border around the table and its cells. It accepts a
numerical value representing the thickness in pixels. For example, `border="1"` sets a border of 1 pixel
width.
2. `width`: The `width` attribute sets the width of the table. It can be specified in pixels (`width="500"`), as
a percentage of the available space (`width="50%"`), or using other CSS units.
3. `align`: This attribute specifies the horizontal alignment of the table with respect to its surrounding
content. The possible values are `"left"`, `"center"`, or `"right"`. For example, `align="center"` centers the
table within its containing element.
4. `bgcolor`: The `bgcolor` attribute sets the background color of the table. It accepts color values in various
formats such as color names (`bgcolor="red"`), hexadecimal codes (`bgcolor="#00FF00"`), or RGB values
(`bgcolor="rgb(255, 0, 0)"`).
Salwa Sulthana
II BCA
Solved Question Bank
29. Describe <time> element with its datetime attribute. (4)
The `<time>` element is an HTML tag used to represent a specific date, time, or both. It can be
useful for marking up dates and times in web content for various purposes, such as displaying the
publication date of an article, the start and end times of an event, or any other time-related information.
The `<time>` element can include a `datetime` attribute, which specifies the machine-readable format of
the date and time being represented. The value of the `datetime` attribute must adhere to the ISO 8601
format, which is widely recognized and supported.
The `datetime` attribute is particularly useful for search engines, screen readers, and other applications that
can extract and process the date and time information in a standardized way. It helps improve accessibility,
searchability, and overall understanding of the content.
Salwa Sulthana
II BCA
Solved Question Bank
32. List and Explain different data types available in JavaScript. (4)
JavaScript has several built-in data types that allow you to store and manipulate different kinds of
values. Here are the main data types in JavaScript:
1.Number: The `Number` data type represents numeric values, both integers and floating-point numbers
2.String: The `String` data type represents sequences of characters enclosed in single or double quotes.
3.Boolean: The `Boolean` data type represents logical values, either `true` or `false`.
4.Null: The `null` data type represents the intentional absence of any object value. It is a special value that
indicates the absence of an object.
5.Undefined: The `undefined` data type represents the absence of a defined value. It is the default value
assigned to a variable that has been declared but not assigned a value.
6.Symbol: The `Symbol` data type represents unique and immutable values that can be used as property
keys in objects. Symbols are typically used to define non-enumerable properties.
7. BigInt: The `BigInt` data type represents arbitrary precision integers. It can store larger integer values
than the `Number` type can handle. `BigInt` values are created by appending `n` to the end of an integer
literal or by using the `BigInt()` constructor.
33. Explain how to define a JavaScript function with proper example. (4)
To define a JavaScript function, you can use the `function` keyword followed by the name of the
function and parentheses `()`. Any parameters the function accepts are listed within the parentheses. The
function body is enclosed in curly braces `{}`.
Here's an example of how to define a JavaScript function that calculates the square of a number:
function square(number) {
var result = number * number;
return result;
}
To use this function, you can simply call it and pass the desired argument:
var squaredNumber = square(5);
console.log(squaredNumber); // Output: 25
34. Explain the following with respect to JavaScript: i) function declaration ii) function constructor
iii) function expression. (6)
In JavaScript, functions play a vital role in organizing and reusing blocks of code. There are different
ways to define and create functions, including function declaration, function constructor, and function
expression. Let's explore each of these concepts in detail:
i) Function Declaration:
A function declaration is the most common and straightforward way to define a function in JavaScript. It
involves using the `function` keyword, followed by the name of the function, a pair of parentheses for
parameters (if any), and a pair of curly braces to enclose the function's body.
Salwa Sulthana
II BCA
Solved Question Bank
ii) Function Constructor:
The function constructor is an alternative way to create functions in JavaScript. It involves using the
`Function` constructor, which is built-in to the language. It takes a variable number of arguments, where
the last argument is the function's body as a string, and the preceding arguments are the parameter names.
iii) Function Expression:
A function expression involves assigning a function to a variable or a property of an object. It's a way to
define a function as an expression, rather than a declaration.
35. Explain how to use event handlers in JavaScript with example (4)
In JavaScript, event handlers are used to respond to specific events that occur in a web page, such
as a button click, mouse movement, or keyboard input. They allow you to define custom code or functions
that will be executed when the specified event occurs.
Salwa Sulthana
II BCA
Solved Question Bank
36. Explain addEventListner() method with example. (4)
The `addEventListener()` method is used in JavaScript to attach an event listener to a specific
element in the HTML document. It allows you to specify a function (or callback) that should be executed
when a particular event occurs on that element. This method is commonly used to make web pages
interactive by responding to user actions or other events.
The syntax for `addEventListener()` is as follows:
element.addEventListener(event, callback, useCapture);
example:
<!DOCTYPE html>
<html>
<head>
<title>Event Listener Example</title>
</head>
<body>
<button id="myButton">Click me!</button>
<script>
// Get a reference to the button element
var button = document.getElementById("myButton");
// Attach an event listener to the button
button.addEventListener("click", function() {
alert("Button clicked!");
});
</script>
</body>
</html>
Salwa Sulthana
II BCA
Solved Question Bank
example:
function Person(name, age)
{
this.name = name;
this.age = age;
}
// Creating objects using the constructor function
var person1 = new Person('John Doe', 25);
var person2 = new Person('Jane Smith', 30);
console.log(person1.name); // Output: John Doe
console.log(person1.age); // Output: 25
console.log(person2.name); // Output: Jane Smith
console.log(person2.age); // Output: 30
Salwa Sulthana
II BCA
Solved Question Bank
39. Explain prompt() method with example.
The `prompt()` method is a built-in function in JavaScript that is used to display a dialog box to the
user, prompting them to enter some input. This method is commonly used to gather user information or
receive user responses in interactive web applications.
The `prompt()` method takes two optional parameters: `message` and `default`. The `message` parameter
is a string that specifies the message or question to be displayed in the dialog box. The `default` parameter
is also a string and represents the default value that is displayed in the input field of the dialog box. If the
user clicks the "OK" button without entering any value, the `prompt()` method will return the default value.
example:
let name = prompt("Please enter your name:", "John Doe");
if (name !== null && name !== "")
{
console.log("Hello, " + name + "!"); // Outputs a greeting with the entered name
}
else
{
console.log("No name entered"); // Outputs a message when no name is entered
}
Salwa Sulthana
II BCA