Skip to main content

Chapter 5

Web Technology

TU BCA past exam questions

Past questions and answers

78 questions set from this chapter, 2 of them more than once. Most repeated first.

  • Asked 2 times
  • 2019 · 5 marks
  • 2021 · 5 marks

Explain tier technology with examples?

Answer

Tier technology (multi-tier or n-tier architecture) divides an application into separate logical or physical layers, each with a specific responsibility, so that each can be developed, deployed, scaled and maintained independently.

1. Single-tier (1-tier): presentation, logic and data are in one program on one machine. Simple but not scalable or shareable. Example: a standalone desktop word processor or MS Access application.

2. Two-tier (client-server):

  • Tier 1, client: the user interface and business logic.
  • Tier 2, server: the database.
  • The client talks directly to the database. Fast and simple, but business logic is tied to the client, scaling is poor, and security is weak. Example: a desktop application connected directly to an SQL Server database.

3. Three-tier:

  • Presentation tier: the user interface (browser, HTML/CSS/JavaScript).
  • Application (business logic) tier: processes requests and applies business rules on a web/application server (PHP, ASP.NET, JSP).
  • Data tier: the database server (MySQL, Oracle, SQL Server).
Browser  <-->  Web/Application Server  <-->  Database

Benefits: better scalability, security (the browser never touches the database directly), reuse and easier maintenance. Example: an online shopping website.

4. N-tier: more tiers are added, for example a separate web server, application server, cache, services tier and database. Used in large enterprise systems such as internet banking.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • Asked 2 times
  • 2021 · 10 marks
  • 2024 · 10 marks

Write a server side script for implementing login. Your program should take username and password as input and redirect to home page if validated otherwise prints an error "try again".

Answer

Login form (login.html)

<form action="login.php" method="post">
  Username: <input type="text" name="username" required><br>
  Password: <input type="password" name="password" required><br>
  <input type="submit" value="Login">
</form>

login.php

<?php
session_start();

$conn = new mysqli("localhost", "root", "", "mydb");
if ($conn->connect_error) {
    die("Connection failed");
}

$username = $_POST['username'];
$password = $_POST['password'];

$stmt = $conn->prepare("SELECT password FROM users WHERE username = ?");
$stmt->bind_param("s", $username);
$stmt->execute();
$result = $stmt->get_result();

if ($row = $result->fetch_assoc() and $row['password'] === $password) {
    $_SESSION['username'] = $username;
    header("Location: home.php");     // redirect to home page
    exit();
} else {
    echo "try again";
}
$conn->close();
?>

home.php

<?php
session_start();
if (!isset($_SESSION['username'])) {
    header("Location: login.html");
    exit();
}
echo "Welcome, " . htmlspecialchars($_SESSION['username']);
?>

The script reads the username and password from $_POST, checks them against the users table, redirects to the home page on success and otherwise prints try again. In production the stored passwords should be hashed and checked with password_verify().

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

Enlist and explain method of using CSS in web page.

Similar questions: What is CSS? Explain the method of (2024)

Answer

CSS can be applied to a web page in three ways.

1. Inline CSS is written in the style attribute of a single element. It affects only that element and has the highest priority, but it mixes content with presentation and cannot be reused.

<p style="color: red; font-size: 18px;">Inline styled text</p>

2. Internal (embedded) CSS is written in a <style> element inside the <head> of the page. It applies to the whole page but not to other pages.

<head>
  <style>
    h1 { color: green; }
    p  { text-align: justify; }
  </style>
</head>

3. External CSS is written in a separate .css file and linked with <link> in the head. One file can style many pages, so it is easy to maintain and the browser caches it. It is the preferred method.

<head>
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
/* style.css */
body { background: #f0f0f0; }

An external stylesheet can also be imported with @import url("style.css"); inside a <style> block.

Priority: when rules conflict, inline overrides internal and external (the latter two follow the order in which they are declared), and the browser default is the lowest.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

What is CSS? Explain the method of using CSS on the web page.

Similar questions: Enlist and explain method of using CSS (2021)

Answer

CSS (Cascading Style Sheets) is a style sheet language that controls how HTML elements look: colours, fonts, spacing, positioning and layout. It separates content from presentation, so one stylesheet can style many pages, and changing the design needs no change to the HTML.

Methods of using CSS on a web page

1. Inline CSS: written in the style attribute of a single element.

<p style="color:red; font-size:18px;">Inline styled text</p>

It affects only that element and has high priority, but it is hard to maintain.

2. Internal (embedded) CSS: written in a <style> tag inside <head>.

<head>
  <style>
    h1 { color: blue; }
    p  { font-family: Arial; }
  </style>
</head>

It applies to the whole page, but it cannot be shared with other pages.

3. External CSS: written in a separate .css file and linked with <link> in <head>.

<link rel="stylesheet" href="style.css">

style.css

body { background: #f4f4f4; }
h1   { color: green; }

One file styles the whole website, so it is the best method for maintenance and faster loading through caching.

4. Imported CSS: an external file loaded with @import url("style.css"); inside a <style> block.

When rules conflict, the cascade order is inline, then internal and external (the later one wins), then browser defaults.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

What is CSS? Discuss types of CSS with example.

Answer

CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation of an HTML (or XML) document: colours, fonts, spacing, layout and positioning. It separates content (HTML) from presentation (CSS), so one style sheet can control many pages, pages are easier to maintain and load faster. Rules have the form selector { property: value; }.

Types of CSS

1. Inline CSS is written in the style attribute of a single element. It affects only that element and has the highest priority, but it is hard to maintain.

<p style="color:blue; font-size:18px;">This is inline styled text.</p>

2. Internal (embedded) CSS is written inside a <style> element in the <head> of the page. It applies to that one page only.

<head>
  <style>
    h1 { color: green; text-align: center; }
    p  { font-family: Arial; }
  </style>
</head>

3. External CSS is written in a separate .css file and linked with <link> in the head. One file can style the whole website, which makes it the best practice.

<link rel="stylesheet" href="style.css">
/* style.css */
body { background-color: #f2f2f2; }
h1   { color: red; }

Priority (cascade order): inline > internal/external (the one declared later wins, with equal specificity) > browser default.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

What is XML? Differentiate XML schema with DTD.

Answer

XML (eXtensible Markup Language) is a W3C standard markup language for storing and transporting data in a structured, self-descriptive, platform-independent text format. Unlike HTML, XML has no predefined tags: the author defines his own tags, and the focus is on what the data is, not how it looks.

<student><name>Ram</name><roll>12</roll></student>

Difference between XML Schema (XSD) and DTD

BasisXML Schema (XSD)DTD
SyntaxWritten in XML itselfSpecial non-XML syntax inherited from SGML
Data typesRich built-in types (string, integer, date, boolean...) and user-defined typesOnly text (#PCDATA, CDATA); no real data types
Namespace supportSupportedNot supported
Occurrence controlExact control with minOccurs, maxOccursOnly ?, *, +
ExtensibilityExtensible; types can be reused and derivedLimited
Parsing / toolsCan be parsed and manipulated with XML tools such as DOMNeeds a separate parser
ComplexityMore verbose and complexSimple and compact
File extension.xsd.dtd

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

List common application of web server. Explain how session works.

Answer

Common applications of a web server

  • Hosting and serving static web pages (HTML, CSS, JavaScript, images) over HTTP/HTTPS.
  • Running server-side scripts and web applications (PHP, ASP.NET, JSP, Node.js) to generate dynamic pages.
  • Handling form submissions and database access for web applications.
  • Hosting web services and REST APIs.
  • File downloading and uploading (FTP-like services over HTTP).
  • Authentication, session management, logging and security (SSL/TLS).
  • Proxying, load balancing and caching (for example Nginx as a reverse proxy).

Examples of web servers: Apache HTTP Server, Microsoft IIS, Nginx.

How a session works

HTTP is a stateless protocol: the server does not remember a client between requests. A session is a server-side mechanism that keeps information about one user across multiple requests.

  1. The user makes the first request to the web application.
  2. The server creates a session, generates a unique session ID, and stores the user's data (login status, cart, preferences) on the server, keyed by that ID.
  3. The server sends the session ID to the browser, normally in a cookie (for example PHPSESSID, ASP.NET_SessionId), or in the URL if cookies are disabled.
  4. On every later request the browser sends the session ID back.
  5. The server uses the ID to find the stored session data and so recognises the user.
  6. The session ends when the user logs out, or after a timeout, when the server destroys the data.
session_start();
$_SESSION['user'] = "Ram";   // stored on the server
echo $_SESSION['user'];      // available on other pages

Because the data stays on the server and only the ID goes to the client, sessions are more secure than storing data in cookies.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

Describe the tags and attributes for a form in HTML document?

Answer

A form in HTML collects user input and sends it to a server for processing. It is created with the <form> element, which contains input controls.

Attributes of <form>

AttributePurpose
actionURL of the script that processes the data
methodHTTP method: get (data in URL) or post (data in request body)
name / idIdentifies the form
targetWhere to show the response (_self, _blank)
enctypeEncoding of data; multipart/form-data for file upload
autocompleteTurns browser autofill on/off
novalidateDisables browser validation on submit

Common form tags

TagDescription
<input>Input field; type is given by type: text, password, email, number, radio, checkbox, file, date, hidden, submit, reset, button
<label>Label for a control (for links it to the control's id)
<textarea>Multi-line text (rows, cols)
<select> with <option>Drop-down list (multiple, selected)
<button>Clickable button (type="submit")
<fieldset> and <legend>Groups related controls with a caption

Common attributes of controls: name, value, placeholder, required, readonly, disabled, maxlength, size, checked, min, max, pattern.

Example

<form action="save.php" method="post">
  <fieldset>
    <legend>Registration</legend>
    <label for="n">Name:</label>
    <input type="text" id="n" name="name" required placeholder="Full name"><br>
    <label>Gender:</label>
    <input type="radio" name="gender" value="male" checked> Male
    <input type="radio" name="gender" value="female"> Female<br>
    <label for="c">Country:</label>
    <select id="c" name="country">
      <option value="np" selected>Nepal</option>
      <option value="in">India</option>
    </select><br>
    <textarea name="msg" rows="3" cols="30"></textarea><br>
    <input type="checkbox" name="agree" required> I agree<br>
    <input type="submit" value="Submit">
    <input type="reset" value="Clear">
  </fieldset>
</form>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

What is anonymous access? Discuss about Integrated windows authentication.

Answer

Anonymous access is an authentication setting of a web server (for example IIS) that lets any user access the site without supplying a username and password. The server does not challenge the user; instead every request is run under a built-in account (in IIS, IUSR, or the application pool identity), whose permissions on files decide what can be viewed. It is used for public websites, and is enabled by default. Its main drawback is that the individual user cannot be identified, so it is not suitable for private data.

Integrated Windows Authentication (IWA)

IWA is a method in which the browser authenticates the user with the credentials of the Windows account he already logged in with, usually without asking him to type a password.

  • Protocols used: Kerberos (in an Active Directory domain) or NTLM.
  • Working: the client requests a protected resource, the server replies 401 Unauthorized with the Negotiate/NTLM header, the browser answers with a hashed token or ticket (the password is never sent in clear text), the server validates it against the Windows domain controller and grants access based on the user's permissions.

Advantages:

  • Single sign-on: no repeated login prompts.
  • Password is not sent over the network in plain text.
  • The user is identified, so access control and auditing are possible.

Disadvantages:

  • Works mainly with Internet Explorer/Edge and a Windows domain; limited across the Internet, firewalls and proxies.
  • Needs client and server to be in the same or trusted domains.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 5 marks

Write short note on following:
• Cookies
• XML DOM

Answer

Cookies

A cookie is a small piece of text data (at most about 4 KB) that a web server sends to the browser, which stores it on the user's computer and returns it with each later request to the same site. It is used because HTTP is stateless.

Uses:

  • Session management: keeping a user logged in, shopping cart.
  • Personalisation: language, theme, preferences.
  • Tracking and analytics: user behaviour, advertising.

Attributes: name=value, expires/max-age (lifetime; without it the cookie is a session cookie that vanishes when the browser closes), path, domain, secure (HTTPS only), HttpOnly (not readable by JavaScript).

Types: session (temporary) and persistent cookies; first-party and third-party cookies.

setcookie("user", "Ram", time() + 86400);   // set, valid for 1 day
echo $_COOKIE["user"];                      // read
document.cookie = "user=Ram; max-age=86400; path=/";

Drawbacks: stored on the client so can be viewed or deleted by the user; size limited; privacy concerns; may be disabled.

XML DOM

The XML Document Object Model is a W3C standard programming interface that treats an XML document as a tree of nodes in memory, so programs can read, navigate, add, modify and delete its content. The whole document is loaded in memory.

Node types: document node, element nodes, attribute nodes, text nodes, comment nodes.

For <book><title>Web</title></book>: the document contains the element book, which contains the element title, which contains the text node "Web".

Properties and methods: nodeName, nodeValue, nodeType, parentNode, childNodes, firstChild, getElementsByTagName(), getAttribute(), createElement(), appendChild(), removeChild().

var xml = new DOMParser().parseFromString(text, "text/xml");
var t = xml.getElementsByTagName("title")[0].childNodes[0].nodeValue;

Advantage: random access and modification of data in any order. Disadvantage: uses much memory for large files.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 10 marks

Differentiate between tags and attributes? Write a HTML and CSS code design your curriculum vitae (CV) using different html elements like (table, image, formatting tags, links).

Answer

Difference between tags and attributes

TagAttribute
A keyword inside angle brackets that defines an HTML element, for example <p>, <h1>, <table>.Extra information given inside the start tag to modify or describe an element.
Tells the browser what type of content it is and how to structure it.Gives properties such as size, colour, link address, identifier.
Usually comes in pairs: opening <p> and closing </p>.Written as name="value" pairs; never in a closing tag.
Example: <img>Example: src, alt, width in <img src="a.jpg" alt="Photo" width="100">

HTML and CSS code for a CV

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Curriculum Vitae</title>
  <style>
    body   { font-family: Arial, sans-serif; width: 700px; margin: 20px auto; background: #f9f9f9; }
    h1     { text-align: center; color: #1a4d8f; margin-bottom: 0; }
    h2     { color: #1a4d8f; border-bottom: 2px solid #1a4d8f; }
    img    { border-radius: 50%; border: 3px solid #1a4d8f; }
    table  { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
    th, td { border: 1px solid #888; padding: 6px; text-align: left; }
    th     { background: #1a4d8f; color: white; }
    a      { color: #c0392b; text-decoration: none; }
  </style>
</head>
<body>
  <h1>Ram Bahadur Thapa</h1>
  <p align="center"><i>BCA Student</i></p>
  <p align="center"><img src="photo.jpg" alt="Photo" width="120" height="120"></p>

  <h2>Personal Information</h2>
  <table>
    <tr><td><b>Address</b></td><td>Kathmandu, Nepal</td></tr>
    <tr><td><b>Phone</b></td><td>98XXXXXXXX</td></tr>
    <tr><td><b>Email</b></td><td><a href="mailto:ram@example.com">ram@example.com</a></td></tr>
    <tr><td><b>Date of birth</b></td><td>2002-05-10</td></tr>
  </table>

  <h2>Objective</h2>
  <p>To work as a <strong>web developer</strong> and apply my skills in a growing organisation.</p>

  <h2>Education</h2>
  <table>
    <tr><th>Level</th><th>Institution</th><th>Year</th><th>Result</th></tr>
    <tr><td>SEE</td><td>ABC School</td><td>2018</td><td>3.6 GPA</td></tr>
    <tr><td>+2</td><td>XYZ College</td><td>2020</td><td>3.4 GPA</td></tr>
    <tr><td>BCA</td><td>Tribhuvan University</td><td>Running</td><td>-</td></tr>
  </table>

  <h2>Skills</h2>
  <ul>
    <li>HTML, CSS, JavaScript</li>
    <li>PHP and MySQL</li>
    <li>Java and C</li>
  </ul>

  <h2>Links</h2>
  <p><a href="https://github.com/ram" target="_blank">GitHub profile</a> |
     <a href="https://linkedin.com/in/ram" target="_blank">LinkedIn</a></p>
</body>
</html>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 10 marks

Develop a simple web page that asks the users input (name, email, phone, gender) and store into database using server side script.

Answer

This example uses HTML for the form and PHP with MySQL as the server-side script.

Database

CREATE DATABASE college;
USE college;
CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100),
  email VARCHAR(100),
  phone VARCHAR(15),
  gender VARCHAR(10)
);

form.html

<!DOCTYPE html>
<html>
<head><title>Registration</title></head>
<body>
  <h2>Registration Form</h2>
  <form action="save.php" method="post">
    Name: <input type="text" name="name" required><br><br>
    Email: <input type="email" name="email" required><br><br>
    Phone: <input type="text" name="phone" pattern="[0-9]{10}" required><br><br>
    Gender:
    <input type="radio" name="gender" value="Male" required> Male
    <input type="radio" name="gender" value="Female"> Female<br><br>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

save.php

<?php
$conn = new mysqli("localhost", "root", "", "college");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$name   = $_POST['name'];
$email  = $_POST['email'];
$phone  = $_POST['phone'];
$gender = $_POST['gender'];

$stmt = $conn->prepare("INSERT INTO users (name, email, phone, gender) VALUES (?, ?, ?, ?)");
$stmt->bind_param("ssss", $name, $email, $phone, $gender);

if ($stmt->execute()) {
    echo "Record saved successfully.";
} else {
    echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>

The form posts the four fields to save.php; the script reads them from $_POST, and inserts them into the users table using a prepared statement, which also prevents SQL injection.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 10 marks

What are the rules for creating XML document? Write a XML code to store following information about student.
• Each student has a name, address, phone and website element.
• Address might appears multiple times.
• Address has attribute named "type" with value permanent and temporary must be 10 digit.

Answer

Rules for creating an XML document (well-formed XML)

  1. It must have exactly one root element that contains all other elements.
  2. Every start tag must have a matching end tag (or be self-closing, <br/>).
  3. Elements must be properly nested: <a><b></b></a>, not <a><b></a></b>.
  4. Tag names are case sensitive: <Name> and <name> differ.
  5. Attribute values must be enclosed in quotes: type="permanent".
  6. Names must start with a letter or underscore, contain no spaces, and not start with xml.
  7. Special characters must be escaped as entities: &lt;, &gt;, &amp;, &quot;, &apos;.
  8. An optional XML declaration <?xml version="1.0" encoding="UTF-8"?> must come first in the file.
  9. Comments are written <!-- ... -->.

XML for student information

The requirement is that each student has a name, address (one or more), phone and website, and the address has a type attribute with the value permanent or temporary. The phone must be 10 digits.

<?xml version="1.0" encoding="UTF-8"?>
<students>
  <student>
    <name>Ram Bahadur Thapa</name>
    <address type="permanent">Pokhara, Kaski</address>
    <address type="temporary">Kathmandu, Baneshwor</address>
    <phone>9841234567</phone>
    <website>https://www.ramthapa.com.np</website>
  </student>
  <student>
    <name>Sita Sharma</name>
    <address type="permanent">Biratnagar, Morang</address>
    <phone>9801234567</phone>
    <website>https://www.sitasharma.com.np</website>
  </student>
</students>

XML Schema to enforce the rules (multiple addresses, type limited to two values, phone exactly 10 digits)

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="students">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="student" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string"/>
              <xs:element name="address" maxOccurs="unbounded">
                <xs:complexType>
                  <xs:simpleContent>
                    <xs:extension base="xs:string">
                      <xs:attribute name="type" use="required">
                        <xs:simpleType>
                          <xs:restriction base="xs:string">
                            <xs:enumeration value="permanent"/>
                            <xs:enumeration value="temporary"/>
                          </xs:restriction>
                        </xs:simpleType>
                      </xs:attribute>
                    </xs:extension>
                  </xs:simpleContent>
                </xs:complexType>
              </xs:element>
              <xs:element name="phone">
                <xs:simpleType>
                  <xs:restriction base="xs:string">
                    <xs:pattern value="[0-9]{10}"/>
                  </xs:restriction>
                </xs:simpleType>
              </xs:element>
              <xs:element name="website" type="xs:anyURI"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

Which of the following provide additional information about HTML elements? (a) Headings (b) Paragraphs (c) Attributes (d) Styles

Answer

(c) Attributes

Attributes are written in the start tag as name="value" pairs and give additional information about an element, for example src and alt for <img> or href for <a>.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

Which of the following is NOT an inline element? (a) <img> (b) <span> (c) <input> (d) None of the above

Answer

(d) None of the above

<img>, <span> and <input> are all inline elements (they do not start on a new line and take only as much width as needed), so none of them is an exception.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

How can you make an e-mail link? (a) <a href="mailto:xxx@yyy"> (b) <mail href="xxx@yyy"> (c) <mail>xxx@yyy</mail> (d) <a href="xxx@yyy">

Answer

(a) <a href="mailto:xxx@yyy">

An email link uses the anchor tag with the mailto: scheme, which opens the user's default mail client. There is no <mail> tag in HTML.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

For XML document to be valid? (a) Document need to be well formed also (b) Document need not to be well formed (c) Document need to be well formed & valid (d) Document validity has no relationship with well formedness

Answer

(a) Document need to be well formed also

A valid XML document must first be well formed (correct syntax) and in addition conform to a DTD or schema. Every valid document is well formed, but not the reverse.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

W3C is stands for (a) World Wide Web Center (b) World Wide Web Company (c) World Wide Web Consortium (d) World Wide Web Certificate

Answer

(c) World Wide Web Consortium

W3C is the international organisation, led by Tim Berners-Lee, that develops web standards such as HTML, CSS and XML.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

XSL is, (a) AN XML based language to create style sheets (b) Extensible solution language (c) A language which is not used in XML (d) Extended stylesheet language

Answer

(a) An XML based language to create style sheets

XSL (Extensible Stylesheet Language) is itself written in XML and is used to transform and format XML documents (XSLT, XSL-FO, XPath).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

CSS uses dot (.) for, (a) Element selector (b) Class selector (c) ID selector (d) Attribute selector

Answer

(b) Class selector

In CSS, a dot is used for a class selector, for example .menu { color: red; }, while # is used for an ID selector.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

Namespace in XML is used to, (a) Distinguishes one XML vocabulary from another (b) Provides the spaces into name (c) Querying language (d) Make duplicate of XML validation

Answer

(a) Distinguishes one XML vocabulary from another

An XML namespace, declared with xmlns, gives element names a unique identity (via a URI) so that elements with the same name from different vocabularies do not conflict.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

A cookie is often used to identify a (a) User (b) Browser (c) Web page (d) Client

Answer

(a) User

A cookie stored in the browser carries an identifier that lets the server recognise a returning user across requests, although strictly it identifies the browser on one device.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2019 · 1 mark

Server side scripts is (a) Visible to the end user (b) Invisible to the end user (c) Defined to user (d) None

Answer

(b) Invisible to the end user

Server-side scripts (PHP, ASP.NET) run on the server and only their output (HTML) is sent to the browser, so the user cannot see the script source.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

What is HTML5? Explain characteristics of HTML5.

Answer

HTML5 is the fifth and current major version of HTML (HyperText Markup Language), the standard markup language for creating web pages. It was developed by WHATWG and W3C and published as a W3C recommendation in 2014. It adds new semantic elements, built-in multimedia, graphics, form controls and JavaScript APIs, so that rich applications can be built without plug-ins such as Flash.

Characteristics of HTML5

  1. Simple doctype and character set: <!DOCTYPE html> and <meta charset="UTF-8">.
  2. Semantic elements: <header>, <nav>, <section>, <article>, <aside>, <footer>, <main>, <figure> make the structure meaningful to browsers, search engines and screen readers.
  3. Native multimedia: <audio> and <video> play media without plug-ins.
  4. Graphics: <canvas> for scriptable 2D drawing and inline SVG for vector graphics.
  5. New form features: input types such as email, date, number, range, color, url, tel, search, and attributes placeholder, required, autofocus, pattern, with built-in validation.
  6. Web storage: localStorage and sessionStorage store more data (about 5 MB) on the client than cookies.
  7. Geolocation API to find the user's location (with permission).
  8. Offline support and Web Workers: application cache/service workers and background scripts.
  9. Drag and drop, contenteditable, and WebSocket for two-way communication.
  10. Cross-platform and mobile friendly: works on desktop and mobile browsers, supports responsive design.
  11. Better error handling and backward compatibility: browsers handle old markup gracefully; deprecated presentational tags (<font>, <center>) are removed in favour of CSS.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

Write HTML tag to generate the following table: - Row 1: empty cell (rowspan 2), "Average" spanning 2 columns, "Red Eyes" (rowspan 2). - Row 2: "Height", "Weight". - Row 3: "Males", "1.5", "0.004", "45%". - Row 4: "Female", "1.4", "0.006", "47%".

Answer

<!DOCTYPE html>
<html>
<head>
  <title>Table</title>
</head>
<body>
  <table border="1" cellpadding="6" cellspacing="0">
    <tr>
      <td rowspan="2"></td>
      <th colspan="2">Average</th>
      <th rowspan="2">Red Eyes</th>
    </tr>
    <tr>
      <th>Height</th>
      <th>Weight</th>
    </tr>
    <tr>
      <td>Males</td>
      <td>1.5</td>
      <td>0.004</td>
      <td>45%</td>
    </tr>
    <tr>
      <td>Female</td>
      <td>1.4</td>
      <td>0.006</td>
      <td>47%</td>
    </tr>
  </table>
</body>
</html>

Explanation: in row 1 the empty cell and "Red Eyes" use rowspan="2" so they extend down into row 2, and "Average" uses colspan="2" to span the Height and Weight columns. Row 2 therefore needs only two cells, "Height" and "Weight". Rows 3 and 4 have four cells each, which gives a 4-column table.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

Design the following website's Menu with use of HTML list and appropriate CSS. Navigation menu with items: Home | News | Contact | About (horizontal, separated by borders).

Answer

<!DOCTYPE html>
<html>
<head>
  <title>Menu</title>
  <style>
    ul.menu {
      list-style-type: none;
      margin: 0;
      padding: 0;
      overflow: hidden;
      background-color: #333;
    }
    ul.menu li {
      float: left;
      border-right: 1px solid #bbb;
    }
    ul.menu li:last-child {
      border-right: none;
    }
    ul.menu li a {
      display: block;
      color: white;
      text-align: center;
      padding: 14px 22px;
      text-decoration: none;
    }
    ul.menu li a:hover {
      background-color: #111;
    }
  </style>
</head>
<body>
  <ul class="menu">
    <li><a href="index.html">Home</a></li>
    <li><a href="news.html">News</a></li>
    <li><a href="contact.html">Contact</a></li>
    <li><a href="about.html">About</a></li>
  </ul>
</body>
</html>

The items are written as an unordered list. CSS removes the bullets, floats each <li> left so the list becomes horizontal, makes each link a block so the whole box is clickable, and gives each item a right border as a separator (the last one has none). A hover colour is added for feedback.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

Compare and contrast between a block-level element and an inline element in HTML?

Answer

BasisBlock-level elementInline element
Line behaviourAlways starts on a new line and the next element also starts on a new lineDoes not start a new line; flows within the text line
WidthTakes the full available width of its parent by defaultTakes only as much width as its content needs
Width/height propertieswidth and height can be setwidth and height have no effect
Margin and paddingAll four sides applyHorizontal margin/padding apply; vertical ones do not push other lines
Content allowedCan contain block and inline elementsShould contain only data and other inline elements
CSS display valuedisplay: blockdisplay: inline
Examples<div>, <p>, <h1>-<h6>, <ul>, <ol>, <li>, <table>, <form>, <section><span>, <a>, <b>, <i>, <strong>, <em>, <img>, <input>
<div>Block 1</div>
<div>Block 2</div>
<span>Inline 1</span> <span>Inline 2</span>

The two divs appear on separate lines, while the two spans sit side by side. The behaviour can be changed with CSS; display: inline-block combines both, allowing width and height on an element that stays in line.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

What is CSS Selector? Explain different types of selector with suitable example.

Answer

A CSS selector is the part of a CSS rule that selects the HTML element(s) to which the declarations in braces are applied.

selector { property:value; }\text{selector}\ \{\ \text{property}: \text{value};\ \}

Types of selectors

  1. Element (type) selector selects all elements of a given tag name.
p { color: blue; }
  1. Class selector selects elements having a given class attribute. It starts with a dot and can be reused on many elements.
.note { background: yellow; }      /* <p class="note"> */
  1. ID selector selects the one element with a given id. It starts with # and must be unique in the page.
#header { height: 80px; }          /* <div id="header"> */
  1. Universal selector * selects every element.
* { margin: 0; padding: 0; }
  1. Group selector applies one rule to several selectors separated by commas.
h1, h2, h3 { font-family: Arial; }
  1. Descendant selector selects elements nested anywhere inside another element. A child selector (>) selects only direct children.
div p { color: red; }        /* any p inside div */
ul > li { list-style: none; } /* only direct li of ul */
  1. Adjacent sibling (+) and general sibling (~) selectors select elements following another element.
h1 + p { font-weight: bold; }
  1. Attribute selector selects elements by attribute or its value.
input[type="text"] { border: 1px solid gray; }
  1. Pseudo-class selector selects an element in a special state, and a pseudo-element selector selects a part of an element.
a:hover { color: red; }
p::first-line { font-weight: bold; }
li:nth-child(odd) { background: #eee; }

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

Why session is required in web development? Explain how you set and remove values stored in Session with suitable example?

Answer

Why a session is required

HTTP is a stateless protocol: the server treats every request as independent and does not remember who made the previous one. A web application, however, must remember a user across pages, for example a logged-in user, shopping-cart items or user preferences. A session solves this by storing the user's data on the server, identified by a unique session ID (kept in a cookie such as PHPSESSID or passed in the URL). Because the data stays on the server, it is more secure than keeping it in cookies, and it can hold larger data. The session ends when the user logs out, or after a timeout or when the browser closes.

Setting, reading and removing session values (PHP)

<?php
// page1.php - start the session and set values
session_start();                       // must be called before any output
$_SESSION['username'] = "Ram";
$_SESSION['role']     = "student";
echo "Session values set.";
?>
<?php
// page2.php - read the values
session_start();
if (isset($_SESSION['username'])) {
    echo "Welcome " . $_SESSION['username'];
} else {
    echo "Please log in.";
}
?>
<?php
// logout.php - remove values
session_start();
unset($_SESSION['role']);      // remove one value
session_unset();               // remove all session variables
session_destroy();             // destroy the session itself
echo "Session removed.";
?>

session_start() creates or resumes a session, $_SESSION[] stores values, unset() removes one value, and session_unset() with session_destroy() clears everything.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 5 marks

Critically analysis the pitfall of the 3-tier technology in comparison with n-tier technology.

Answer

3-tier architecture divides an application into the presentation tier (browser/UI), the application (business logic) tier and the data tier (database). N-tier architecture extends this with further separate tiers or layers, such as a web server, caching, a service or API layer, a messaging queue and separate data services, each of which can be deployed and scaled independently.

Pitfalls of 3-tier compared with n-tier

Point3-tiern-tier
ScalabilityThe business-logic tier is one large block; scaling means replicating the whole tier, even if only one function is busyEach tier or service is scaled independently, so only the busy part is scaled
FlexibilityLogic for many functions is mixed in one tier, so changes affect the whole tierConcerns are separated into more layers (e.g. security, caching, services), so changes are localised
ReuseBusiness logic is tied to one applicationServices can be reused by many clients (web, mobile, other systems)
PerformanceNo dedicated caching, load balancing or messaging tier, so the application and database become bottlenecksCaches, load balancers and queues reduce load on the database
Fault toleranceA failure in the middle tier brings the whole application downRedundant, isolated tiers limit the effect of a failure
TechnologyOne technology stack for the whole middle tierEach tier can use the best-suited technology

Critical view: the pitfalls of 3-tier are its coarse granularity, scaling limits and a monolithic middle tier that is hard to maintain as the system grows. N-tier is not free of cost, though: it is more complex to design, deploy, test and secure, has more network hops (latency), and is more expensive to manage. For small and medium applications 3-tier is simpler and sufficient; for large, high-traffic systems n-tier is better.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 10 marks

Design the following layout of webpage with use of div and appropriate CSS. - Logo - Navigation - Header Banner - Two-column content area: Side Bar (left) | Body Area (right) - Footer

Answer

The page is built from div elements: logo, navigation, header banner, a container holding a left sidebar and right body area, and a footer.

<!DOCTYPE html>
<html>
<head>
<title>Page Layout</title>
<style>
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body { font-family: Arial, sans-serif; width: 960px; margin: 0 auto; }

  #logo   { background: #f4c542; height: 70px; padding: 20px; font-size: 24px; font-weight: bold; }
  #nav    { background: #333; }
  #nav a  { display: inline-block; color: #fff; padding: 12px 18px; text-decoration: none; }
  #nav a:hover { background: #555; }
  #banner { background: #6fa8dc; height: 150px; padding: 50px; text-align: center; font-size: 28px; color: #fff; }

  #content { overflow: hidden; }            /* contains the floats */
  #sidebar { float: left;  width: 25%; background: #eee; min-height: 300px; padding: 15px; }
  #body    { float: right; width: 75%; background: #fafafa; min-height: 300px; padding: 15px; }

  #footer { clear: both; background: #222; color: #fff; text-align: center; padding: 15px; }
</style>
</head>
<body>
  <div id="logo">LOGO</div>

  <div id="nav">
    <a href="#">Home</a>
    <a href="#">About</a>
    <a href="#">Services</a>
    <a href="#">Contact</a>
  </div>

  <div id="banner">Header Banner</div>

  <div id="content">
    <div id="sidebar">Side Bar</div>
    <div id="body">Body Area</div>
  </div>

  <div id="footer">Footer &copy; 2020</div>
</body>
</html>

The sidebar floats left with width 25% and the body area floats right with width 75%, which gives the two-column layout. The footer uses clear: both so it sits below both columns.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 10 marks

Write a server-site script for login process assume that user name and password have already exist on database TU under the user table (id, user, password). The login form includes: Username field, Password field, Login button, Lost Your Password link, and Sign Up link.

Answer

Login form (login.html)

<form action="login.php" method="post">
  Username: <input type="text" name="username" required><br>
  Password: <input type="password" name="password" required><br>
  <input type="submit" name="login" value="Login"><br>
  <a href="lost_password.php">Lost Your Password?</a> |
  <a href="signup.php">Sign Up</a>
</form>

Server-side script (login.php), PHP with MySQL, database TU, table user(id, user, password)

<?php
session_start();

$conn = new mysqli("localhost", "root", "", "TU");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $username = $_POST['username'];
    $password = $_POST['password'];

    // prepared statement prevents SQL injection
    $stmt = $conn->prepare("SELECT id, password FROM user WHERE user = ?");
    $stmt->bind_param("s", $username);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($row = $result->fetch_assoc()) {
        // use password_verify() if passwords are stored hashed;
        // here the stored value is compared directly
        if ($row['password'] === $password || password_verify($password, $row['password'])) {
            $_SESSION['user_id']  = $row['id'];
            $_SESSION['username'] = $username;
            header("Location: home.php");
            exit();
        }
    }
    echo "Invalid username or password. <a href='login.html'>Try again</a>";
}
$conn->close();
?>

The script connects to the database TU, looks up the submitted username in the user table and compares the password. On success it stores the user in a session and redirects to the home page; otherwise it prints an error message.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2020 · 10 marks

What are the rules for Well-formed XML document? Create a sample well-formed XML and validate it with DTD Schema.

Answer

Rules for a well-formed XML document

  1. There must be exactly one root element that contains all other elements.
  2. Every start tag must have a matching end tag (or be self-closing, e.g. <br/>).
  3. Elements must be properly nested; <a><b></b></a> is correct, <a><b></a></b> is not.
  4. Tag names are case-sensitive; <Name> and </name> do not match.
  5. Attribute values must be quoted (single or double), and an attribute name must not repeat in one element.
  6. Names must start with a letter or underscore, and must not contain spaces.
  7. Special characters must be escaped as entities: &lt;, &gt;, &amp;, &quot;, &apos;.
  8. The XML declaration, if present, must be the first line: <?xml version="1.0" encoding="UTF-8"?>.

Sample well-formed XML with an internal DTD (students.xml)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE students [
  <!ELEMENT students (student+)>
  <!ELEMENT student (name, program, semester)>
  <!ATTLIST student id CDATA #REQUIRED>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT program (#PCDATA)>
  <!ELEMENT semester (#PCDATA)>
]>
<students>
  <student id="101">
    <name>Sita Sharma</name>
    <program>BCA</program>
    <semester>3</semester>
  </student>
  <student id="102">
    <name>Hari Thapa</name>
    <program>BCA</program>
    <semester>3</semester>
  </student>
</students>

Validation: the DTD states that students contains one or more student elements, each student has the child elements name, program and semester in that order, and a required attribute id. A validating parser checks the document against these declarations. The document above is both well-formed (it follows the rules) and valid (it matches the DTD). If a student lacked name, or had no id, the parser would report a validity error.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

Write a form to collect details of a user such as name, address, radio button to choose subject of book he wants to buy, dropdown to choose favorite author.

Answer

<!DOCTYPE html>
<html>
<head>
  <title>Book Buyer Details</title>
</head>
<body>
  <h2>User Details Form</h2>
  <form action="process.php" method="post">

    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required><br><br>

    <label for="address">Address:</label>
    <input type="text" id="address" name="address" required><br><br>

    <p>Choose the subject of the book you want to buy:</p>
    <input type="radio" id="s1" name="subject" value="Programming" checked>
    <label for="s1">Programming</label>
    <input type="radio" id="s2" name="subject" value="Mathematics">
    <label for="s2">Mathematics</label>
    <input type="radio" id="s3" name="subject" value="Literature">
    <label for="s3">Literature</label><br><br>

    <label for="author">Favorite author:</label>
    <select id="author" name="author">
      <option value="">-- Select --</option>
      <option value="Laxmi Prasad Devkota">Laxmi Prasad Devkota</option>
      <option value="Bhanubhakta Acharya">Bhanubhakta Acharya</option>
      <option value="Dennis Ritchie">Dennis Ritchie</option>
      <option value="Other">Other</option>
    </select><br><br>

    <input type="submit" value="Submit">
    <input type="reset" value="Reset">
  </form>
</body>
</html>

The radio buttons share the same name so that only one subject can be chosen, and the select element gives the dropdown list of authors.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

How XSL is different from CSS? Explain.

Answer

XSL (Extensible Stylesheet Language) is a family of languages for transforming and presenting XML. Its main parts are XSLT (transforms XML into another XML, HTML or text) and XSL-FO (formatting objects for print/PDF output). CSS (Cascading Style Sheets) only specifies how elements of HTML or XML are displayed.

PointCSSXSL
PurposeStyling and presentation onlyTransformation of XML plus formatting
SyntaxOwn non-XML syntax (selector { property: value })Itself a well-formed XML document
Structure changeCannot add, remove, reorder or compute contentCan filter, sort, reorder, add text and calculate values
SelectionSelectorsXPath expressions
Programming featuresNoneLoops (for-each), conditions (if, choose), variables, templates
OutputSame document rendered by the browserNew document (HTML, XML, text) generated from the source
Applied toHTML and XMLXML
ComplexitySimple, easy to learnMore complex and powerful

Example: CSS can make every <name> red, but only XSL can list the names in a table sorted alphabetically:

<xsl:for-each select="students/student">
  <xsl:sort select="name"/>
  <tr><td><xsl:value-of select="name"/></td></tr>
</xsl:for-each>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

Define Session. Explain its use with example.

Answer

A session is a way of storing information about a user on the server across multiple page requests. When a user first visits, the server creates a unique session ID, sends it to the browser (normally as a cookie), and keeps the user's data (such as login status or cart items) on the server under that ID. On each later request the browser sends the ID back and the server retrieves the data. This overcomes the stateless nature of HTTP.

Uses

  • keeping a user logged in across pages
  • shopping carts
  • storing user preferences
  • protecting pages from unauthorised access

Example (PHP)

<?php
// login.php
session_start();
$_SESSION['user'] = "Ram";
echo "Logged in";
?>
<?php
// dashboard.php
session_start();
if (isset($_SESSION['user'])) {
    echo "Welcome, " . $_SESSION['user'];
} else {
    header("Location: login.html");   // not logged in
    exit();
}
?>
<?php
// logout.php
session_start();
session_unset();
session_destroy();
header("Location: login.html");
?>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

Write an example of server side script to insert data in database.

Answer

The following PHP script receives data from an HTML form and inserts it into a MySQL table student(id, name, email) in database college.

Form (form.html)

<form action="insert.php" method="post">
  Name:  <input type="text" name="name" required><br>
  Email: <input type="email" name="email" required><br>
  <input type="submit" value="Save">
</form>

insert.php

<?php
$conn = new mysqli("localhost", "root", "", "college");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$name  = $_POST['name'];
$email = $_POST['email'];

$stmt = $conn->prepare("INSERT INTO student (name, email) VALUES (?, ?)");
$stmt->bind_param("ss", $name, $email);

if ($stmt->execute()) {
    echo "Record inserted successfully.";
} else {
    echo "Error: " . $stmt->error;
}

$stmt->close();
$conn->close();
?>

The script connects to the database, reads the submitted values from $_POST, and inserts them using a prepared statement, which also protects against SQL injection.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 5 marks

Explain the following with example:
a) table tag
b) Image map

Answer

(a) table tag

The <table> tag creates a table to display data in rows and columns. Its main related tags are <tr> (table row), <th> (header cell), <td> (data cell), <caption>, <thead>, <tbody> and <tfoot>. Attributes colspan and rowspan merge cells.

<table border="1" cellpadding="5">
  <caption>Marks</caption>
  <tr>
    <th>Name</th><th>Subject</th><th>Marks</th>
  </tr>
  <tr>
    <td>Ram</td><td>Web Technology</td><td>78</td>
  </tr>
  <tr>
    <td>Sita</td><td>Web Technology</td><td>85</td>
  </tr>
  <tr>
    <td colspan="2">Total</td><td>163</td>
  </tr>
</table>

(b) Image map

An image map makes different regions of one image clickable, each linking to a different destination. The image uses the usemap attribute, which refers to a <map> element containing <area> tags. The shape can be rect, circle or poly, and coords gives the coordinates.

<img src="planets.jpg" usemap="#planetmap" width="400" height="200" alt="Planets">

<map name="planetmap">
  <area shape="rect"   coords="0,0,100,100"  href="sun.html"   alt="Sun">
  <area shape="circle" coords="200,100,50"   href="earth.html" alt="Earth">
  <area shape="poly"   coords="300,10,350,10,330,80" href="moon.html" alt="Moon">
</map>

Clicking the rectangle opens sun.html, the circle opens earth.html and the polygon opens moon.html.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 10 marks

Write an HTML script with CSS for following elements with effects:
a. Link: after visited red color and before visited blue color.
b. Table with odd rows pink and even rows blue color.
c. Text color-green, Text-indentation-2cm, Text case-uppercase.

Answer

<!DOCTYPE html>
<html>
<head>
<title>CSS Effects</title>
<style>
  /* a. Link colours: blue before visit, red after visit */
  a:link    { color: blue; }
  a:visited { color: red; }

  /* b. Table: odd rows pink, even rows blue */
  table { border-collapse: collapse; width: 60%; }
  td, th { border: 1px solid black; padding: 6px; }
  tr:nth-child(odd)  { background-color: pink; }
  tr:nth-child(even) { background-color: lightblue; }

  /* c. Text: green, 2cm indentation, uppercase */
  p.text {
    color: green;
    text-indent: 2cm;
    text-transform: uppercase;
  }
</style>
</head>
<body>
  <h3>a. Link</h3>
  <a href="http://www.example.com">Visit example</a>

  <h3>b. Table</h3>
  <table>
    <tr><td>Row 1</td><td>Odd</td></tr>
    <tr><td>Row 2</td><td>Even</td></tr>
    <tr><td>Row 3</td><td>Odd</td></tr>
    <tr><td>Row 4</td><td>Even</td></tr>
  </table>

  <h3>c. Text</h3>
  <p class="text">this text is green, indented by two centimetres and shown in uppercase.</p>
</body>
</html>

a:link and a:visited style unvisited and visited links. tr:nth-child(odd) and tr:nth-child(even) colour alternate rows. text-indent, color and text-transform produce the text effects. (Link pseudo-classes must be in the order link, visited, hover, active.)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2021 · 10 marks

Explain the key component of XML file. Write an XML to describe "address" as an element and "state, city, municipality and house-no" as its attributes. Also define XSD for the XML file.

Answer

Key components of an XML file

  1. XML declaration gives the version and encoding: <?xml version="1.0" encoding="UTF-8"?>.
  2. Root element: the single top-level element that contains all others.
  3. Elements: the building blocks, written with start and end tags, which can hold text or child elements.
  4. Attributes: name-value pairs inside the start tag giving extra information about an element.
  5. Text (character data): the content of an element.
  6. Comments: <!-- comment -->.
  7. Processing instructions, CDATA sections (<![CDATA[ ... ]]>), and entities (&lt;, &amp;).
  8. DTD or XSD: optional definitions that describe the permitted structure.

XML with address element and attributes (address.xml)

<?xml version="1.0" encoding="UTF-8"?>
<address state="Bagmati" city="Kathmandu" municipality="Kageshwori Manohara" house-no="45"/>

XSD for the file (address.xsd)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="address">
    <xs:complexType>
      <xs:attribute name="state"        type="xs:string" use="required"/>
      <xs:attribute name="city"         type="xs:string" use="required"/>
      <xs:attribute name="municipality" type="xs:string" use="required"/>
      <xs:attribute name="house-no"     type="xs:string" use="required"/>
    </xs:complexType>
  </xs:element>

</xs:schema>

To link the XML to the schema, the root element is written as <address xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="address.xsd" state="..." ... />. The schema declares one element address with four required attributes of type string, so an XML file missing any of them is invalid.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

Create the following table using the HTML elements.

Answer

The table in the question is not shown, so the following is a typical table using the elements normally asked for (caption, header cells, colspan and rowspan).

<!DOCTYPE html>
<html>
<head><title>Table</title></head>
<body>
<table border="1" cellpadding="6" cellspacing="0">
  <caption>Class Routine</caption>
  <tr>
    <th rowspan="2">Day</th>
    <th colspan="2">Time</th>
  </tr>
  <tr>
    <th>10:00 - 11:00</th>
    <th>11:00 - 12:00</th>
  </tr>
  <tr>
    <td>Sunday</td>
    <td>Web Technology</td>
    <td>Statistics</td>
  </tr>
  <tr>
    <td>Monday</td>
    <td colspan="2" align="center">Lab</td>
  </tr>
</table>
</body>
</html>

<table> defines the table, <tr> a row, <th> a heading cell and <td> a data cell. rowspan makes a cell span several rows and colspan several columns; border, cellpadding and cellspacing control the appearance.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What are the various font-related attributes in CSS? Explain with suitable example.

Answer

CSS provides the following font properties to control the appearance of text.

PropertyPurposeValues
font-familytypeface (list with fallbacks)"Times New Roman", serif, Arial, sans-serif
font-sizesize of text16px, 1.2em, 120%, large
font-weightboldnessnormal, bold, 100 to 900
font-styleslantnormal, italic, oblique
font-variantsmall capitalsnormal, small-caps
fontshorthand for all of the aboveitalic bold 16px Arial

Example

<style>
  h1 {
    font-family: "Georgia", serif;
    font-size: 32px;
    font-weight: bold;
  }
  p.intro {
    font-family: Arial, sans-serif;
    font-size: 1.1em;
    font-style: italic;
    font-variant: small-caps;
  }
  p.short {
    font: italic bold 14px/20px Verdana, sans-serif;  /* shorthand */
  }
</style>

<h1>Heading</h1>
<p class="intro">This paragraph uses italic small-caps text.</p>
<p class="short">Shorthand font declaration.</p>

In the shorthand, font-size and font-family are required and must come last, in that order.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

How does Tier Technology function inside the architectural framework of a web application?

Answer

Tier technology splits a web application into separate logical (and often physical) layers, each with a single responsibility, so that the layers can be developed, deployed and scaled independently.

Tiers in a typical web application (3-tier)

  1. Presentation tier (client): the web browser, which shows HTML, CSS and JavaScript, takes user input and sends HTTP requests.
  2. Application (logic) tier: the web/application server (e.g. Apache with PHP, Tomcat, Node.js) that receives requests, runs business rules, performs validation and talks to the database.
  3. Data tier: the database server (e.g. MySQL) that stores, retrieves and updates data.

How it works

  1. The user submits a request from the browser.
  2. The web server passes it to the application logic.
  3. The logic tier queries the data tier and receives the result.
  4. The logic tier builds an HTML response and returns it to the browser.

The tiers talk only to their neighbours: the browser never accesses the database directly, which improves security.

Advantages: separation of concerns, easier maintenance, scalability of each tier (e.g. adding more application servers), reuse of business logic, and better security. Larger systems add more tiers (caching, load balancer, API/service tier), which is called n-tier architecture.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

How does a web server process and handle HTTP requests and responses with example?

Answer

A web server (such as Apache or Nginx) is software that listens on a port (80 for HTTP, 443 for HTTPS), receives HTTP requests from clients and returns HTTP responses.

Steps in handling a request

  1. The browser resolves the domain name to an IP address (DNS) and opens a TCP connection to the server.
  2. The browser sends an HTTP request: a request line (method, path, version), headers and an optional body.
  3. The server parses the request and maps the URL to a resource.
  4. Static content (HTML, CSS, images) is read from the file system and sent. Dynamic content (PHP etc.) is passed to a script interpreter, which may query a database, and the generated output is returned.
  5. The server sends an HTTP response: a status line, headers and a body.
  6. The connection is closed or kept alive for more requests, and the server logs the request.

Example

Request:

GET /index.html HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html

Response:

HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1250

<html> ... page content ... </html>

Common status codes are 200 OK, 301 (moved), 404 Not Found and 500 Internal Server Error. Methods such as GET (fetch data) and POST (send data in the body) tell the server what to do. The server handles many clients at once using multiple processes or threads.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

Create a server site script to use cookie variables for the login and logout process without using databases.

Answer

Cookies are small pieces of data stored in the browser. Here the username is kept in a cookie, so no database is used (the credentials are fixed in the script for demonstration).

login.php

<?php
$validUser = "admin";
$validPass = "1234";

if (isset($_POST['login'])) {
    if ($_POST['username'] == $validUser && $_POST['password'] == $validPass) {
        // set cookie for 1 hour
        setcookie("user", $_POST['username'], time() + 3600, "/");
        header("Location: welcome.php");
        exit();
    } else {
        echo "Invalid login.";
    }
}
?>
<form method="post">
  Username: <input type="text" name="username"><br>
  Password: <input type="password" name="password"><br>
  <input type="submit" name="login" value="Login">
</form>

welcome.php

<?php
if (isset($_COOKIE['user'])) {
    echo "Welcome, " . htmlspecialchars($_COOKIE['user']);
    echo "<br><a href='logout.php'>Logout</a>";
} else {
    header("Location: login.php");
    exit();
}
?>

logout.php

<?php
setcookie("user", "", time() - 3600, "/");   // expire the cookie
header("Location: login.php");
exit();
?>

setcookie() must be called before any output. Login creates the cookie, pages check $_COOKIE, and logout deletes it by setting a past expiry time.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

Use server-site scripting to calculate the x using the data from two text boxes.

Answer

The question does not state what xx is, so the script below calculates x=a+bx = a + b from the two text boxes. Other operations only need a change in the formula.

<?php
$x = "";
if (isset($_POST['calc'])) {
    $a = $_POST['num1'];
    $b = $_POST['num2'];

    if (is_numeric($a) && is_numeric($b)) {
        $x = $a + $b;
    } else {
        $x = "Please enter numbers only.";
    }
}
?>
<!DOCTYPE html>
<html>
<body>
<form method="post" action="">
  First number:  <input type="text" name="num1"><br>
  Second number: <input type="text" name="num2"><br>
  <input type="submit" name="calc" value="Calculate">
</form>

<?php
if ($x !== "") {
    echo "x = " . $x;
}
?>
</body>
</html>

The values typed in the two text boxes are sent by POST, read with $_POST, validated with is_numeric(), combined into xx and displayed on the same page. For example, 12+812 + 8 gives x=20x = 20.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 5 marks

What are the new form elements introduced in HTML5 and how do they differ from previous versions?

Answer

HTML5 added new input types, attributes and elements that provide built-in validation and better user interfaces without JavaScript.

New input types

TypePurpose
emailvalidates email format
urlvalidates a URL
numbernumeric input with min, max, step
rangeslider
date, time, datetime-local, month, weekdate and time pickers
colorcolour picker
searchsearch box
teltelephone number

New form elements

  • <datalist>: gives a list of suggestions for an input
  • <output>: shows the result of a calculation
  • <progress> and <meter>: show progress or a measured value
  • <keygen> was added but has been removed

New attributes: placeholder, required, autofocus, autocomplete, pattern (regular expression validation), min, max, multiple, form, novalidate.

Example

<form>
  <input type="email" name="mail" placeholder="Email" required>
  <input type="date" name="dob">
  <input type="range" name="r" min="0" max="10">
  <input type="color" name="c">
  <input list="cities" name="city">
  <datalist id="cities">
    <option value="Kathmandu"><option value="Pokhara">
  </datalist>
  <input type="submit">
</form>

Difference from earlier versions: HTML 4 had only text, password, checkbox, radio, file, hidden, submit, reset, button and image inputs. All validation and date pickers had to be written in JavaScript or provided by plug-ins, whereas HTML5 provides them natively, giving better usability, less code and mobile-friendly keyboards.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

Given an XML document that contains a list of products with the following elements: productname, category, price, and quantity, write an XSLT stylesheet that:
a) Filters out any products that have a quantity less than 10.
b) Groups the remaining products by category and creates a new XML document with a new element called "category" that contains the products within that category as child elements.
c) Within each category element, sort the products by price in descending order.
d) Transforms the element "productname" into an attribute of each product element.
e) Add a new element called "total-price" to each product element, which contains the total price of the product (price × quantity).

Answer

Sample input (products.xml)

<?xml version="1.0" encoding="UTF-8"?>
<products>
  <product>
    <productname>Pen</productname>
    <category>Stationery</category>
    <price>20</price>
    <quantity>100</quantity>
  </product>
  <product>
    <productname>Laptop</productname>
    <category>Electronics</category>
    <price>60000</price>
    <quantity>5</quantity>
  </product>
  <product>
    <productname>Mouse</productname>
    <category>Electronics</category>
    <price>800</price>
    <quantity>30</quantity>
  </product>
</products>

XSLT stylesheet (products.xsl), XSLT 1.0 with Muenchian grouping

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="xml" indent="yes"/>

  <!-- (a) only products with quantity >= 10 are grouped -->
  <xsl:key name="by-cat" match="product[quantity &gt;= 10]" use="category"/>

  <xsl:template match="/products">
    <catalog>
      <!-- (b) one category element per distinct category -->
      <xsl:for-each select="product[quantity &gt;= 10]
                 [generate-id() = generate-id(key('by-cat', category)[1])]">
        <category name="{category}">

          <!-- (c) sort products in the category by price, descending -->
          <xsl:for-each select="key('by-cat', category)">
            <xsl:sort select="price" data-type="number" order="descending"/>

            <!-- (d) productname becomes an attribute -->
            <product productname="{productname}">
              <price><xsl:value-of select="price"/></price>
              <quantity><xsl:value-of select="quantity"/></quantity>
              <!-- (e) total price = price x quantity -->
              <total-price><xsl:value-of select="price * quantity"/></total-price>
            </product>
          </xsl:for-each>

        </category>
      </xsl:for-each>
    </catalog>
  </xsl:template>
</xsl:stylesheet>

Resulting output for the sample data

The laptop (quantity 5<105 < 10) is removed. Pen: 20×100=200020 \times 100 = 2000. Mouse: 800×30=24000800 \times 30 = 24000.

<catalog>
  <category name="Stationery">
    <product productname="Pen">
      <price>20</price><quantity>100</quantity><total-price>2000</total-price>
    </product>
  </category>
  <category name="Electronics">
    <product productname="Mouse">
      <price>800</price><quantity>30</quantity><total-price>24000</total-price>
    </product>
  </category>
</catalog>

The key is defined only on products with quantity at least 10 (part a), generate-id() picks the first product of each category to create the category elements (part b), xsl:sort orders by price descending (part c), productname="{productname}" is an attribute value template that turns the element into an attribute (part d), and price * quantity calculates the new total-price element (part e).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

Make a script for the server site to display the following data by reading from a database and saving any new values that the user has updated.
Choose Id: 123
Username
Password:
Confirm Password:
Email:
Update

Answer

The page shows a user's record chosen by Id, displays it in editable fields, and saves the changes when Update is clicked. Assume a MySQL database mydb with table users(id, username, password, email).

update.php

<?php
$conn = new mysqli("localhost", "root", "", "mydb");
if ($conn->connect_error) { die("Connection failed"); }

$message = "";

/* 1. Save changes when Update is pressed */
if (isset($_POST['update'])) {
    if ($_POST['password'] !== $_POST['confirm']) {
        $message = "Password and Confirm Password do not match.";
    } else {
        $stmt = $conn->prepare(
            "UPDATE users SET username=?, password=?, email=? WHERE id=?");
        $stmt->bind_param("sssi",
            $_POST['username'], $_POST['password'], $_POST['email'], $_POST['id']);
        $stmt->execute();
        $message = "Record updated.";
    }
}

/* 2. Read the selected id (default 123) and fetch the record */
$id = isset($_REQUEST['id']) ? (int)$_REQUEST['id'] : 123;
$stmt = $conn->prepare("SELECT username, password, email FROM users WHERE id=?");
$stmt->bind_param("i", $id);
$stmt->execute();
$row = $stmt->get_result()->fetch_assoc();

/* list of ids for the drop-down */
$ids = $conn->query("SELECT id FROM users");
?>
<!DOCTYPE html>
<html>
<body>
<p><?php echo $message; ?></p>

<!-- choose the id -->
<form method="get">
  Choose Id:
  <select name="id" onchange="this.form.submit()">
    <?php while ($r = $ids->fetch_assoc()) { ?>
      <option value="<?php echo $r['id']; ?>"
        <?php if ($r['id'] == $id) echo "selected"; ?>>
        <?php echo $r['id']; ?>
      </option>
    <?php } ?>
  </select>
</form>

<?php if ($row) { ?>
<form method="post">
  <input type="hidden" name="id" value="<?php echo $id; ?>">
  Username: <input type="text" name="username"
            value="<?php echo htmlspecialchars($row['username']); ?>"><br>
  Password: <input type="password" name="password"
            value="<?php echo htmlspecialchars($row['password']); ?>"><br>
  Confirm Password: <input type="password" name="confirm"><br>
  Email: <input type="email" name="email"
            value="<?php echo htmlspecialchars($row['email']); ?>"><br>
  <input type="submit" name="update" value="Update">
</form>
<?php } else { echo "No record found."; } ?>
</body>
</html>

The first form selects the Id (123 by default). The script reads that user's record with a prepared SELECT and fills the fields. When the user edits the values and presses Update, the two passwords are compared and an UPDATE query saves the new values. In a real system passwords should be stored hashed.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2022 · 10 marks

Make a well-formed XML document as per the diagram, then use an appropriate XSD document to validate it with the following restrictions:
a) The username must have a minimum of 8 characters.
b) The character limit for posts is 5 to 8.
c) The password must be 8 characters long and begin with Aa-Zz.
d) The gender must be one of male, female, or other.
e) The salary should range from Rs. 25,000 to Rs. 50,000.

Answer

The diagram is not shown, so the document below uses the fields named in the restrictions: a user with username, post, password, gender and salary.

Well-formed XML (users.xml)

<?xml version="1.0" encoding="UTF-8"?>
<users xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="users.xsd">
  <user>
    <username>ramshrestha</username>
    <post>Manager</post>
    <password>Abcd1234</password>
    <gender>male</gender>
    <salary>40000</salary>
  </user>
</users>

XSD (users.xsd)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="users">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="user" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="username" type="usernameType"/>
              <xs:element name="post"     type="postType"/>
              <xs:element name="password" type="passwordType"/>
              <xs:element name="gender"   type="genderType"/>
              <xs:element name="salary"   type="salaryType"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <!-- a. username: minimum 8 characters -->
  <xs:simpleType name="usernameType">
    <xs:restriction base="xs:string">
      <xs:minLength value="8"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- b. post: 5 to 8 characters -->
  <xs:simpleType name="postType">
    <xs:restriction base="xs:string">
      <xs:minLength value="5"/>
      <xs:maxLength value="8"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- c. password: exactly 8 characters, beginning with a letter -->
  <xs:simpleType name="passwordType">
    <xs:restriction base="xs:string">
      <xs:length value="8"/>
      <xs:pattern value="[A-Za-z].*"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- d. gender: male, female or other -->
  <xs:simpleType name="genderType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="male"/>
      <xs:enumeration value="female"/>
      <xs:enumeration value="other"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- e. salary: Rs. 25,000 to Rs. 50,000 -->
  <xs:simpleType name="salaryType">
    <xs:restriction base="xs:decimal">
      <xs:minInclusive value="25000"/>
      <xs:maxInclusive value="50000"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

Checking the sample against the restrictions: ramshrestha has 11 characters (≥8\ge 8); Manager has 7 characters (between 5 and 8); Abcd1234 has exactly 8 characters and starts with a letter; male is in the enumeration; Rs 40000 lies within [25000,50000][25000, 50000]. The document is therefore valid.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is an image map? Describe the key steps involved in creating a client image map in HTML using necessary tags and attributes.

Answer

An image map is an image in which different regions (hotspots) act as separate hyperlinks. Clicking different parts of one picture takes the user to different URLs. A client-side image map is processed by the browser itself, using the <map> and <area> elements, so no server request is needed to decide which region was clicked.

Key steps to create a client-side image map

  1. Insert the image and bind it to a map using the usemap attribute of <img>. Its value is # followed by the map name.
  2. Define the map with <map name="...">. The name must match the usemap value.
  3. Define each hotspot inside <map> with an <area> tag, using these attributes:
    • shape: rect, circle, poly or default.
    • coords: coordinates in pixels. For rect they are x1,y1,x2,y2 (top-left and bottom-right). For circle they are x,y,radius. For poly they are x1,y1,x2,y2,....
    • href: the target URL of the hotspot.
    • alt: alternative text, required for accessibility.
    • target (optional): where the link opens.
  4. Test the coordinates so the hotspots cover the intended regions.
<img src="campus.jpg" width="400" height="300" alt="Campus map" usemap="#campusmap">

<map name="campusmap">
  <area shape="rect"   coords="10,10,150,100"  href="library.html" alt="Library">
  <area shape="circle" coords="250,150,50"     href="lab.html"     alt="Computer Lab">
  <area shape="poly"   coords="300,20,380,20,340,90" href="hall.html" alt="Exam Hall">
</map>

Here the image is linked to the map campusmap. Clicking the rectangle opens library.html, the circle opens lab.html, and the triangle opens hall.html.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is session? Explain how session works with proper example.

Answer

A session is a server-side mechanism for storing information about a user across multiple page requests. HTTP is stateless, so the server does not remember a visitor between requests. A session solves this by giving each visitor a unique session ID and keeping that visitor's data (login status, cart, preferences) on the server.

How a session works

  1. The user makes the first request. The script calls session_start(), and the server creates a unique session ID.
  2. The server sends this ID to the browser, normally in a cookie such as PHPSESSID.
  3. The data is stored in $_SESSION on the server, in a file or database. Only the ID travels to the client.
  4. On each later request the browser sends the ID back. The server finds the matching data and makes $_SESSION available again.
  5. When the user logs out, or the session times out, session_destroy() removes the data.

Example (PHP)

login.php

<?php
session_start();
$_SESSION['username'] = "Ram";
echo "Session set. <a href='profile.php'>Go to profile</a>";
?>

profile.php

<?php
session_start();
if (isset($_SESSION['username'])) {
    echo "Welcome, " . $_SESSION['username'];
} else {
    echo "Please login first.";
}
?>

logout.php

<?php
session_start();
session_unset();
session_destroy();
?>

The value stored in login.php is still available in profile.php because both pages use the same session ID.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is CSS? Explain CSS Box model along with its related properties and example.

Answer

CSS (Cascading Style Sheets) is a style sheet language used to describe the presentation of HTML documents, such as colours, fonts, spacing and layout. It separates content (HTML) from design, so one stylesheet can control many pages.

CSS Box Model

Every HTML element is treated as a rectangular box. From inside to outside, the box has four parts:

  1. Content: the text or image, sized by width and height.
  2. Padding: transparent space between the content and the border (padding).
  3. Border: a line around the padding (border).
  4. Margin: transparent space outside the border, which separates the element from its neighbours (margin).

With the default box-sizing: content-box:

Total width=width+paddingL+R+borderL+R+marginL+R\text{Total width} = \text{width} + \text{padding}_{L+R} + \text{border}_{L+R} + \text{margin}_{L+R}

With box-sizing: border-box, width already includes the padding and border.

Related properties

  • width, height, min-width, max-width
  • padding, padding-top/right/bottom/left
  • border, border-width, border-style, border-color, border-radius
  • margin, margin-top/right/bottom/left
  • box-sizing, overflow

Example

<style>
  .box {
    width: 200px;
    padding: 20px;
    border: 5px solid navy;
    margin: 30px;
  }
</style>
<div class="box">Box model demo</div>

Here the total width is 200+2(20)+2(5)=250200 + 2(20) + 2(5) = 250 px, and the space the box occupies including margin is 250+2(30)=310250 + 2(30) = 310 px.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is tier Architecture? Differentiate two-tier technology with three-tier technology.

Answer

Tier architecture (multi-tier architecture) is a way of dividing an application into separate logical layers, each with its own responsibility. The layers are usually presentation (user interface), application or business logic, and data storage. Each tier can be developed, deployed and scaled independently.

Two-tier architecture: a client tier (UI and business logic) talks directly to a database server tier.

Three-tier architecture: a client tier (presentation), a middle application server tier (business logic), and a database tier. The client never talks to the database directly.

BasisTwo-tierThree-tier
LayersClient and database serverClient, application server and database server
Business logicPlaced in the client (fat client) or in the databasePlaced in the separate middle tier
CommunicationClient connects directly to the databaseClient talks to the application server, which talks to the database
ScalabilityPoor; performance drops with many usersGood; each tier scales independently
SecurityLower, since the database is exposed to clientsHigher, since the database is hidden behind the middle tier
MaintenanceHarder; a logic change means updating every clientEasier; a change is made once on the server
Cost and complexitySimple and cheapMore complex and costly
ExampleSmall desktop application using a local DBWeb application (browser, PHP/Java server, MySQL)

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is web server? Explain different functions of web server.

Answer

A web server is software (and the machine that runs it) that stores web resources and delivers them to clients over HTTP/HTTPS. A browser sends a request, and the web server returns the requested page, image or data. Examples are Apache, Nginx and Microsoft IIS.

Functions of a web server

  1. Handling HTTP requests and responses: it receives requests (GET, POST, etc.) from browsers and returns responses with a status code (200, 404, 500) and the content.
  2. Serving static content: it delivers HTML, CSS, JavaScript, images and documents stored on disk.
  3. Serving dynamic content: it passes requests to server-side engines such as PHP, ASP.NET or Java, and returns the generated output.
  4. Virtual hosting: one server hosts many websites or domains.
  5. Security: it supports HTTPS/SSL-TLS, authentication, access control and IP restrictions.
  6. Logging: it records requests, errors and access details for monitoring and troubleshooting.
  7. Session and cookie support: it helps keep track of users across requests.
  8. Load handling and caching: it manages many simultaneous connections and caches content to improve speed.
  9. URL mapping and redirection: it maps URLs to files or scripts and redirects requests.
  10. File upload and download management.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

What is well formed XML? Explain different ways of DTD implementation for XML documents.

Answer

Well-formed XML

An XML document is well-formed when it follows the basic syntax rules of XML:

  • There is exactly one root element.
  • Every start tag has a matching end tag (or the element is self-closed).
  • Elements are properly nested, with no overlapping.
  • Tag names are case-sensitive.
  • Attribute values are enclosed in quotes.
  • Special characters are escaped (&lt;, &amp;).
<?xml version="1.0"?>
<student>
  <name>Sita</name>
  <age>20</age>
</student>

A well-formed document is valid only if it also conforms to a DTD or schema.

Ways of implementing a DTD

A DTD (Document Type Definition) defines the structure and the legal elements and attributes of an XML document. It can be implemented in two ways.

1. Internal DTD: the DTD is written inside the XML file, in the DOCTYPE declaration.

<?xml version="1.0"?>
<!DOCTYPE student [
  <!ELEMENT student (name, age)>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT age (#PCDATA)>
]>
<student>
  <name>Sita</name>
  <age>20</age>
</student>

It is simple, but it cannot be reused across documents.

2. External DTD: the DTD is stored in a separate .dtd file and linked from the XML document.

student.dtd

<!ELEMENT student (name, age)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT age (#PCDATA)>

XML file

<!DOCTYPE student SYSTEM "student.dtd">

Many documents can share one DTD, so it is easier to maintain. An external DTD can be referenced as SYSTEM (by a local file or URL) or as PUBLIC (by a public identifier plus a fallback URL), for example <!DOCTYPE student PUBLIC "-//ABC//DTD Student//EN" "student.dtd">.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 5 marks

Define XPath? Explain different elements required to create XSLT document.

Answer

XPath (XML Path Language) is a query language used to select nodes (elements, attributes, text) from an XML document by describing a path through its tree structure. It is used mainly inside XSLT and XQuery.

Examples: /library/book selects all book elements under the root; //title selects every title anywhere; /library/book[@id='1']/price selects by attribute; book[price>500] selects by a condition.

Elements required to create an XSLT document

XSLT (Extensible Stylesheet Language Transformations) transforms XML into HTML, text or other XML. The main elements are:

  1. <xsl:stylesheet> (or <xsl:transform>): the root element, with the version and the XSL namespace xmlns:xsl="http://www.w3.org/1999/XSL/Transform".
  2. <xsl:output>: sets the output format (html, xml, text).
  3. <xsl:template match="...">: defines a rule for a node pattern. match="/" matches the whole document.
  4. <xsl:value-of select="...">: writes the value of the selected node.
  5. <xsl:for-each select="...">: loops over a set of nodes.
  6. <xsl:if test="..."> and <xsl:choose>/<xsl:when>/<xsl:otherwise>: conditional processing.
  7. <xsl:sort select="...">: sorts the nodes.
  8. <xsl:apply-templates>: applies matching templates to child nodes.

The XML file links to the stylesheet with <?xml-stylesheet type="text/xsl" href="style.xsl"?>.

<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <html><body>
      <xsl:for-each select="library/book">
        <p><xsl:value-of select="title"/></p>
      </xsl:for-each>
    </body></html>
  </xsl:template>
</xsl:stylesheet>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

Design form to accept name, email, phone, gender, country and validate them using server script with following rules and store them into database called "store" and table "information".
i. All fields are required.
ii. Phone number must contain 10 digit.
iii. Email must be valid format.

Answer

Database setup (database store, table information)

CREATE DATABASE store;
USE store;
CREATE TABLE information (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(100) NOT NULL,
  email VARCHAR(100) NOT NULL,
  phone CHAR(10) NOT NULL,
  gender VARCHAR(10) NOT NULL,
  country VARCHAR(50) NOT NULL
);

Form: form.html

<!DOCTYPE html>
<html>
<head><title>Registration Form</title></head>
<body>
  <h2>Registration</h2>
  <form method="post" action="save.php">
    Name: <input type="text" name="name"><br><br>
    Email: <input type="text" name="email"><br><br>
    Phone: <input type="text" name="phone"><br><br>
    Gender:
    <input type="radio" name="gender" value="Male"> Male
    <input type="radio" name="gender" value="Female"> Female
    <input type="radio" name="gender" value="Other"> Other<br><br>
    Country:
    <select name="country">
      <option value="">--Select--</option>
      <option value="Nepal">Nepal</option>
      <option value="India">India</option>
      <option value="Other">Other</option>
    </select><br><br>
    <input type="submit" value="Submit">
  </form>
</body>
</html>

Server script: save.php

<?php
$errors = [];

$name    = trim($_POST['name'] ?? '');
$email   = trim($_POST['email'] ?? '');
$phone   = trim($_POST['phone'] ?? '');
$gender  = $_POST['gender'] ?? '';
$country = $_POST['country'] ?? '';

// i. all fields required
if ($name === '' || $email === '' || $phone === '' || $gender === '' || $country === '') {
    $errors[] = "All fields are required.";
}
// ii. phone must contain exactly 10 digits
if ($phone !== '' && !preg_match('/^[0-9]{10}$/', $phone)) {
    $errors[] = "Phone number must contain 10 digits.";
}
// iii. email must be valid
if ($email !== '' && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
    $errors[] = "Email format is invalid.";
}

if (!empty($errors)) {
    foreach ($errors as $e) echo "<p style='color:red'>$e</p>";
    echo "<a href='form.html'>Go back</a>";
    exit;
}

$conn = new mysqli("localhost", "root", "", "store");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$stmt = $conn->prepare(
  "INSERT INTO information (name, email, phone, gender, country) VALUES (?, ?, ?, ?, ?)"
);
$stmt->bind_param("sssss", $name, $email, $phone, $gender, $country);

if ($stmt->execute()) {
    echo "Data saved successfully.";
} else {
    echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>

The script first checks the three rules on the server and prints the errors. Only valid data reaches the database. A prepared statement is used so the input cannot cause SQL injection.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

Write HTML and CSS code to design following layout. Phone:01-4545445 Address: Kupandole KathmanduSocial Media (List/Link)
Logo[Image] Website name
menue
recent postPost 1 Title
Post 2 Title
Post 3 Title
Post 4 Title
Post 5 Title
[image]
Description......paragraph
footer

Answer

The layout has a header (logo and website name, phone, address and social media list), a menu, a main area with a "recent post" sidebar, then an image with a description paragraph, and a footer.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Website</title>
<style>
  * { box-sizing: border-box; }
  body { margin: 0; font-family: Arial, sans-serif; }

  header { display: flex; justify-content: space-between; align-items: center;
           background: #f2f2f2; padding: 10px 20px; }
  .brand { display: flex; align-items: center; }
  .brand img { width: 60px; height: 60px; margin-right: 15px; }
  .brand h1 { margin: 0; }
  .contact { font-size: 14px; }
  .contact ul { list-style: none; margin: 5px 0 0; padding: 0; display: flex; gap: 10px; }
  .contact a { text-decoration: none; color: #0645ad; }

  nav { background: #333; }
  nav ul { list-style: none; margin: 0; padding: 0; display: flex; }
  nav a { display: block; color: #fff; padding: 12px 20px; text-decoration: none; }
  nav a:hover { background: #555; }

  .wrapper { display: flex; }
  aside { width: 25%; background: #e8e8e8; padding: 15px; }
  aside ul { padding-left: 18px; }
  main { width: 75%; padding: 15px; }
  main img { max-width: 100%; height: auto; }

  footer { background: #333; color: #fff; text-align: center; padding: 12px; }
</style>
</head>
<body>

<header>
  <div class="brand">
    <img src="logo.png" alt="Logo">
    <h1>Website Name</h1>
  </div>
  <div class="contact">
    Phone: 01-4545445<br>
    Address: Kupandole, Kathmandu
    <ul>
      <li><a href="https://facebook.com">Facebook</a></li>
      <li><a href="https://twitter.com">Twitter</a></li>
      <li><a href="https://youtube.com">YouTube</a></li>
    </ul>
  </div>
</header>

<nav>
  <ul>
    <li><a href="#">Home</a></li>
    <li><a href="#">About</a></li>
    <li><a href="#">Services</a></li>
    <li><a href="#">Contact</a></li>
  </ul>
</nav>

<div class="wrapper">
  <aside>
    <h3>Recent Post</h3>
    <ul>
      <li>Post 1 Title</li>
      <li>Post 2 Title</li>
      <li>Post 3 Title</li>
      <li>Post 4 Title</li>
      <li>Post 5 Title</li>
    </ul>
  </aside>

  <main>
    <img src="banner.jpg" alt="Featured image">
    <p>Description ...... This is the main description paragraph of the page.</p>
  </main>
</div>

<footer>
  &copy; 2024 Website Name. All rights reserved.
</footer>

</body>
</html>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2023 · 10 marks

Write a valid and well-formed XML to store details of visitor list of ABC College with following details and validate record with following information:
  1. Record must include details of name, mobile, department, related contact person, date, entry time, exit time and visitor number as attribute.
  2. Mobile must be 10 digit. Visitor may not have any contact person.
  3. Record must belong to Admin, IT, Account and Exam Department.

Answer

The record is stored in XML and validated with a DTD. The mobile rule (10 digits) and the optional contact person are handled as follows. A DTD cannot check the number of digits, so it is checked with an XML Schema pattern, shown after the DTD version. The optional contact person uses ? in the DTD, and the department is limited to four values with an enumerated attribute.

XML with DTD (visitors.xml)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE visitors [
  <!ELEMENT visitors (visitor+)>
  <!ELEMENT visitor (name, mobile, department, contact_person?, date, entry_time, exit_time)>
  <!ATTLIST visitor visitor_no ID #REQUIRED>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT mobile (#PCDATA)>
  <!ELEMENT department (#PCDATA)>
  <!ELEMENT contact_person (#PCDATA)>
  <!ELEMENT date (#PCDATA)>
  <!ELEMENT entry_time (#PCDATA)>
  <!ELEMENT exit_time (#PCDATA)>
]>
<visitors>
  <visitor visitor_no="V001">
    <name>Ram Sharma</name>
    <mobile>9841234567</mobile>
    <department>Admin</department>
    <contact_person>Hari Thapa</contact_person>
    <date>2025-01-15</date>
    <entry_time>10:00</entry_time>
    <exit_time>10:45</exit_time>
  </visitor>
  <visitor visitor_no="V002">
    <name>Sita Rai</name>
    <mobile>9812345678</mobile>
    <department>IT</department>
    <date>2025-01-15</date>
    <entry_time>11:15</entry_time>
    <exit_time>12:00</exit_time>
  </visitor>
</visitors>

Note: with an ID attribute, the value must begin with a letter, so V001 is used. The second visitor has no contact_person, which the DTD allows through ?.

XML Schema validation (visitors.xsd), which also enforces the 10-digit mobile and the four departments:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="mobileType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{10}"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="deptType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Admin"/>
      <xs:enumeration value="IT"/>
      <xs:enumeration value="Account"/>
      <xs:enumeration value="Exam"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="visitors">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="visitor" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="name" type="xs:string"/>
              <xs:element name="mobile" type="mobileType"/>
              <xs:element name="department" type="deptType"/>
              <xs:element name="contact_person" type="xs:string" minOccurs="0"/>
              <xs:element name="date" type="xs:date"/>
              <xs:element name="entry_time" type="xs:time"/>
              <xs:element name="exit_time" type="xs:time"/>
            </xs:sequence>
            <xs:attribute name="visitor_no" type="xs:string" use="required"/>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>

To use it, link the XML root with <visitors xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="visitors.xsd"> and remove the DOCTYPE. The xs:time type needs seconds, so write times as 10:00:00.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

What is XML? Write rules to create XML document with example.

Answer

XML (eXtensible Markup Language) is a markup language used to store and transport data in a structured, human-readable and machine-readable form. Unlike HTML, XML has no predefined tags. The author defines tags that describe the data, and XML is concerned with what the data is, not how it is displayed.

Rules to create an XML document

  1. The document may begin with an XML declaration: <?xml version="1.0" encoding="UTF-8"?>.
  2. There must be exactly one root element containing all other elements.
  3. Every start tag must have a matching end tag, or be self-closing like <br/>.
  4. Elements must be properly nested: <a><b></b></a>, not <a><b></a></b>.
  5. Tag names are case-sensitive: <Name> and <name> are different.
  6. Tag names must start with a letter or underscore, and must not contain spaces.
  7. Attribute values must be quoted: <book id="1">.
  8. Special characters must be escaped with entities: &lt;, &gt;, &amp;, &quot;, &apos;.
  9. Comments are written as <!-- comment -->.

Example

<?xml version="1.0" encoding="UTF-8"?>
<library>
  <book id="1">
    <title>Web Technology</title>
    <author>A. Sharma</author>
    <price>550</price>
  </book>
  <book id="2">
    <title>Database Systems</title>
    <author>R. Thapa</author>
    <price>620</price>
  </book>
</library>

A document that follows these rules is well-formed.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

Explain HTML form elements with suitable example.

Answer

An HTML form collects user input and sends it to a server for processing. It is created with the <form> element, whose action attribute gives the URL that handles the data and whose method attribute (get or post) gives how it is sent.

Common form elements

ElementPurpose
<form>Container for all form controls
<input type="text">Single-line text
<input type="password">Masked text
<input type="radio">Choose one of several options
<input type="checkbox">Choose several options
<input type="submit"> / resetSend or clear the form
<input type="email">, number, date, fileTyped input
<textarea>Multi-line text
<select> with <option>Drop-down list
<label>Caption for a control
<button>Clickable button
<fieldset> and <legend>Group related controls
<input type="hidden">Value sent without display

Example

<form action="register.php" method="post">
  <fieldset>
    <legend>Student Registration</legend>

    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required><br><br>

    <label>Password:</label>
    <input type="password" name="pass"><br><br>

    Gender:
    <input type="radio" name="gender" value="M"> Male
    <input type="radio" name="gender" value="F"> Female<br><br>

    Hobbies:
    <input type="checkbox" name="hobby" value="music"> Music
    <input type="checkbox" name="hobby" value="sports"> Sports<br><br>

    Course:
    <select name="course">
      <option value="bca">BCA</option>
      <option value="bit">BIT</option>
    </select><br><br>

    Comments:<br>
    <textarea name="comments" rows="3" cols="30"></textarea><br><br>

    <input type="submit" value="Submit">
    <input type="reset" value="Clear">
  </fieldset>
</form>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

What is XPath? Write XSLT code to display your books information (Title, price ISBN, subject code) store into XML.

Answer

XPath (XML Path Language) is a language for selecting nodes (elements, attributes, text) from an XML document using path expressions over its tree. For example, /books/book/title selects all titles, //book[price>500] selects books costing more than 500, and //book/@isbn selects the ISBN attributes. XSLT uses XPath in its select and match attributes.

XML file: books.xml

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="books.xsl"?>
<books>
  <book>
    <title>Web Technology</title>
    <price>550</price>
    <isbn>978-9937-1-0001</isbn>
    <subject_code>CACS201</subject_code>
  </book>
  <book>
    <title>Database Management System</title>
    <price>620</price>
    <isbn>978-9937-1-0002</isbn>
    <subject_code>CACS202</subject_code>
  </book>
</books>

XSLT file: books.xsl

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output method="html"/>
  <xsl:template match="/">
    <html>
      <body>
        <h2>My Books</h2>
        <table border="1" cellpadding="5">
          <tr bgcolor="#cccccc">
            <th>Title</th>
            <th>Price (Rs)</th>
            <th>ISBN</th>
            <th>Subject Code</th>
          </tr>
          <xsl:for-each select="books/book">
            <tr>
              <td><xsl:value-of select="title"/></td>
              <td><xsl:value-of select="price"/></td>
              <td><xsl:value-of select="isbn"/></td>
              <td><xsl:value-of select="subject_code"/></td>
            </tr>
          </xsl:for-each>
        </table>
      </body>
    </html>
  </xsl:template>
</xsl:stylesheet>

When books.xml is opened in a browser, the XSLT turns each book into a row of an HTML table.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

Why server side programming is important for web development? Explain with its major features.

Answer

Server-side programming means writing programs that run on the web server, not in the browser. The server runs the code (PHP, ASP.NET, JSP, Node.js, etc.), and sends only the generated output (usually HTML) to the client.

Why it is important

  • Dynamic content: pages are generated from user input, time or database data, such as a personalised dashboard.
  • Database access: only server code can safely read and write the database (MySQL, etc.), enabling login, registration, shopping and so on.
  • Security: source code, database credentials and business logic stay hidden from users. Validation and authentication done on the server cannot be bypassed from the browser.
  • Browser independence: the output is plain HTML, so it works in any browser regardless of what the client supports.
  • Session and user management: the server keeps track of users using sessions and cookies.
  • Centralised maintenance: a change is made once on the server and applies to all users.
  • Handling heavy work: processing, file handling and email sending are done on the server.

Major features

  1. Processing of form data (GET and POST).
  2. Database connectivity and CRUD operations.
  3. Session and cookie management.
  4. File upload, file handling and email sending.
  5. Authentication and authorization.
  6. Server-side validation and error handling.
  7. Generating dynamic HTML, JSON, XML or PDF output.
  8. Support for frameworks and code reuse (include files, functions, OOP).

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

Why session is important for web development, write a server side script to create, store, retrieve and remove session and cookies.

Answer

Importance of sessions and cookies

HTTP is stateless: the server forgets the user after each request. Sessions (data kept on the server) and cookies (data kept in the browser) let a website remember users between pages. They are needed for login and authentication, shopping carts, user preferences, "remember me" features, and tracking visits. A session is more secure than a cookie because the data stays on the server and only an ID is sent to the client.

Session script (PHP)

<?php
// CREATE and STORE
session_start();
$_SESSION['username'] = "Ram";
$_SESSION['role']     = "student";

// RETRIEVE
echo "User: " . $_SESSION['username'];   // Ram

// REMOVE a single variable
unset($_SESSION['role']);

// REMOVE all session data and destroy the session
session_unset();
session_destroy();
?>

Cookie script (PHP)

<?php
// CREATE and STORE (expires in 1 hour)
setcookie("user", "Ram", time() + 3600, "/");

// RETRIEVE (available from the next request)
if (isset($_COOKIE['user'])) {
    echo "Welcome " . $_COOKIE['user'];
} else {
    echo "Cookie not set.";
}

// REMOVE (set the expiry time in the past)
setcookie("user", "", time() - 3600, "/");
?>

session_start() must be called before any output. setcookie() must also be called before any output because it sends an HTTP header.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 5 marks

Explain multi-tier technology with its advantage and disadvantages.

Answer

Multi-tier (n-tier) technology divides an application into several logical layers, each running as a separate tier, possibly on different machines. Each tier talks only to the tier next to it.

Typical tiers

  1. Presentation tier: the user interface (browser, HTML/CSS/JS).
  2. Application (business logic) tier: processes requests, applies rules, and handles validation and calculations (PHP, Java, .NET).
  3. Data tier: the database server (MySQL, Oracle) that stores and retrieves data.

More tiers, such as a separate service, caching or integration tier, can be added in larger systems.

Flow: the client sends a request to the application server, which queries the database, processes the result and sends the response back to the client.

Advantages

  • Scalability: each tier can be scaled independently.
  • Maintainability: a change in one tier does not affect the others.
  • Security: the database is hidden behind the middle tier and not accessible directly from clients.
  • Reusability: business logic can be shared by many clients (web, mobile).
  • Flexibility: technologies can be changed per tier, and teams can work in parallel.
  • Reliability: failure or load in one tier can be handled with replication or load balancing.

Disadvantages

  • Complexity: design, deployment and testing are harder.
  • Higher cost: more servers, hardware and skilled staff are needed.
  • Slower response: extra network hops between tiers add latency.
  • Difficult debugging: tracing errors across several tiers is harder.
  • More maintenance and management effort.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 10 marks

Compare XML Schema with DTD. Write XML schema to describe student as root element, name as child element with first_name, middle_name, last_name, city as child elements with its content "KTM", "PKR", "LPT" and rollno as its attribute.

Answer

Comparison of XML Schema and DTD

BasisDTDXML Schema (XSD)
SyntaxSpecial non-XML syntaxWritten in XML itself
Data typesAlmost none (#PCDATA, CDATA)Rich types: string, integer, date, boolean, custom types
Namespace supportNoYes
Occurrence controlOnly ?, *, +Exact control with minOccurs, maxOccurs
ExtensibilityLimited, no inheritanceTypes can be extended and restricted
RestrictionsCannot restrict patterns or rangesPatterns, enumerations, lengths, ranges
Parsing and toolsNeeds a separate parser for the syntaxCan be processed with ordinary XML tools
ComplexitySimple and shortMore verbose and powerful

XML Schema for the student

The city element is limited to the values KTM, PKR and LPT, and rollno is an attribute of student.

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:simpleType name="cityType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="KTM"/>
      <xs:enumeration value="PKR"/>
      <xs:enumeration value="LPT"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="student">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="name">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="first_name"  type="xs:string"/>
              <xs:element name="middle_name" type="xs:string" minOccurs="0"/>
              <xs:element name="last_name"   type="xs:string"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="city" type="cityType"/>
      </xs:sequence>
      <xs:attribute name="rollno" type="xs:integer" use="required"/>
    </xs:complexType>
  </xs:element>

</xs:schema>

A valid XML instance

<?xml version="1.0"?>
<student rollno="12" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="student.xsd">
  <name>
    <first_name>Hari</first_name>
    <middle_name>Prasad</middle_name>
    <last_name>Sharma</last_name>
  </name>
  <city>KTM</city>
</student>

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2024 · 10 marks

Create web page with following details.
a) Create basic structure.
b) Add header section to the top of page which contain logo and search bar.
c) Create two column layout of (25%, 75%) width and put important list into first one and image gallery into second one.
d) Add footer section, which includes address of company and copyright information.
e) Also add some basic CSS using external stylesheet.

Answer

Files: index.html and style.css.

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Company</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>

  <!-- header with logo and search bar -->
  <header>
    <img src="logo.png" alt="Company Logo" class="logo">
    <form action="search.php" method="get" class="search">
      <input type="text" name="q" placeholder="Search...">
      <button type="submit">Search</button>
    </form>
  </header>

  <!-- two column layout: 25% and 75% -->
  <div class="container">
    <aside class="sidebar">
      <h3>Important Links</h3>
      <ul>
        <li><a href="#">Notices</a></li>
        <li><a href="#">Admissions</a></li>
        <li><a href="#">Results</a></li>
        <li><a href="#">Downloads</a></li>
      </ul>
    </aside>

    <main class="gallery">
      <h3>Image Gallery</h3>
      <img src="img1.jpg" alt="Image 1">
      <img src="img2.jpg" alt="Image 2">
      <img src="img3.jpg" alt="Image 3">
      <img src="img4.jpg" alt="Image 4">
    </main>
  </div>

  <!-- footer -->
  <footer>
    <p>Address: Kupandole, Lalitpur, Nepal</p>
    <p>&copy; 2024 My Company. All rights reserved.</p>
  </footer>

</body>
</html>

style.css

* { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: Arial, sans-serif; }

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1f3a5f;
  color: #fff;
  padding: 10px 20px;
}
.logo { height: 50px; }
.search input  { padding: 6px; width: 200px; }
.search button { padding: 6px 12px; cursor: pointer; }

.container { display: flex; min-height: 400px; }

.sidebar {
  width: 25%;
  background: #eef2f7;
  padding: 15px;
}
.sidebar ul { list-style: none; }
.sidebar li { margin: 8px 0; }
.sidebar a  { text-decoration: none; color: #1f3a5f; }

.gallery {
  width: 75%;
  padding: 15px;
}
.gallery img {
  width: 30%;
  margin: 5px;
  border: 2px solid #ccc;
}

footer {
  background: #1f3a5f;
  color: #fff;
  text-align: center;
  padding: 15px;
}

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

What is client-side and server-side image maps? Explain with example.

Answer

An image map lets different regions of one image link to different URLs. There are two types.

Client-side image map

The map is defined in the HTML page using <map> and <area>. The browser works out which region was clicked and goes directly to the linked URL. No server processing is needed, so it is fast, works offline, and shows the link in the status bar when hovering.

<img src="shapes.png" alt="Shapes" usemap="#shapemap">
<map name="shapemap">
  <area shape="rect"   coords="0,0,100,100"  href="square.html" alt="Square">
  <area shape="circle" coords="200,50,40"    href="circle.html" alt="Circle">
</map>

Server-side image map

The image is placed inside an anchor, and the <img> tag carries the ismap attribute. When the user clicks, the browser sends the pixel coordinates of the click to the server as a query string (?x,y). A server program holding the map definition decides which URL to go to.

<a href="/cgi-bin/imagemap.cgi">
  <img src="shapes.png" alt="Shapes" ismap>
</a>

A click at (45, 30) requests /cgi-bin/imagemap.cgi?45,30.

Difference

BasisClient-sideServer-side
ProcessingBrowserWeb server
Tagsusemap, <map>, <area>ismap inside <a>
SpeedFaster, no extra requestSlower, needs a server round trip
Server scriptNot requiredRequired
AccessibilityBetter, supports alt text per areaPoor

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Differentiate between inline, internal, and external CSS with examples.

Answer

CSS can be applied to an HTML page in three ways.

BasisInline CSSInternal CSSExternal CSS
LocationIn the style attribute of an elementIn a <style> tag inside <head>In a separate .css file linked with <link>
ScopeOnly that one elementThe whole single pageEvery page that links to the file
ReusabilityNoneWithin the page onlyHighly reusable across the site
MaintenanceHardModerateEasiest, one place to change
PriorityHighestMediumLowest (when equal, the later rule wins)
Page loadNo extra fileNo extra fileExtra request, but cached by the browser

Inline

<h1 style="color:red; text-align:center;">Hello</h1>

Internal

<head>
  <style>
    p { color: blue; font-size: 16px; }
  </style>
</head>
<body><p>Styled paragraph</p></body>

External

index.html

<head>
  <link rel="stylesheet" href="style.css">
</head>

style.css

p { color: green; font-size: 16px; }

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Explain 2-tier and 3-tier architecture with proper diagrams.

Answer

2-tier architecture

The application has two layers: a client tier (user interface and usually the business logic) and a data tier (the database server). The client connects directly to the database.

+-------------------+            +-------------------+
|   Client Tier     |  <------>  |   Database Tier   |
| (UI + Logic)      |   SQL      | (DBMS / Storage)  |
+-------------------+            +-------------------+
  • Simple, quick to develop, and fast for a small number of users.
  • Example: a desktop application connecting directly to a local database.
  • Drawbacks: poor scalability, the database is exposed to clients, and any logic change means updating every client.

3-tier architecture

A middle application tier is added between the client and the database. The client never accesses the database directly.

+----------------+      +--------------------+      +----------------+
| Presentation   | ---> | Application Tier   | ---> | Data Tier      |
| Tier (Browser) | <--- | (Business Logic,   | <--- | (Database      |
|  HTML/CSS/JS   |      |  Web Server, PHP)  |      |  Server)       |
+----------------+      +--------------------+      +----------------+
  1. Presentation tier: displays information and takes user input.
  2. Application tier: handles requests, business rules, validation and processing.
  3. Data tier: stores and retrieves data.
  • Better scalability, security, maintainability and reusability, since each tier can change independently.
  • Example: a web application with a browser, a PHP/Java server and a MySQL database.
  • Drawbacks: more complex and costly than 2-tier, with more network hops.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

What is a Formal Public Identifier (FPI)? Describe its purpose and explain the syntax used to define an FPI with appropriate examples.

Answer

A Formal Public Identifier (FPI) is a structured text string that uniquely names a public resource, such as a DTD or an entity, independent of where the file is stored. It is used in the PUBLIC form of the DOCTYPE declaration (in SGML, HTML and XML). Because it names the resource and not a location, the same DTD can be recognised everywhere, and a parser can look it up in a local catalog instead of downloading it.

Purpose

  • It identifies a resource uniquely, whatever its file location.
  • It lets applications use a locally cached copy through a catalog, giving faster access.
  • If the catalog does not recognise it, the system identifier (URL) following it is used as a fallback.
  • It records the owner, document type and language.

Syntax

prefix // owner // description // language\texttt{prefix // owner // description // language}

Written as "-//Owner//DTD Description//Language", it has four parts separated by //:

  1. Prefix (-, + or ISO): - means the owner is not a registered standard body; + means a registered owner; ISO is an ISO standard.
  2. Owner identifier: the organisation that owns the DTD (for example W3C).
  3. Description: the type and name of the document (for example DTD HTML 4.01). Fields are separated by single spaces.
  4. Language: a two-letter language code (for example EN).

The declaration has the form:

<!DOCTYPE rootname PUBLIC "FPI" "system-URL">

Examples

HTML 4.01:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  "http://www.w3.org/TR/html4/strict.dtd">

XHTML 1.0 Strict:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

A user-defined XML document:

<!DOCTYPE student PUBLIC "-//ABC College//DTD Student 1.0//EN" "student.dtd">

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Define DTD. Why XSLT is it important in real-time XML data processing?

Answer

DTD (Document Type Definition) is a set of declarations that defines the legal structure of an XML document: which elements and attributes are allowed, their order, how often they may occur, and their content type. A document that follows its DTD is called valid.

<!DOCTYPE student [
  <!ELEMENT student (name, age)>
  <!ELEMENT name (#PCDATA)>
  <!ELEMENT age  (#PCDATA)>
  <!ATTLIST student rollno CDATA #REQUIRED>
]>

Importance of XSLT in real-time XML data processing

XSLT (Extensible Stylesheet Language Transformations) converts an XML document into another format (HTML, plain text or another XML structure) using XPath and template rules.

  • Format conversion: systems that exchange data as XML (banking feeds, news, web services) need it in another structure. XSLT transforms it without changing programs.
  • Separation of data and presentation: the same XML can be shown as a web page, a mobile view or a printable report using different stylesheets.
  • Real-time display: incoming XML is transformed on the fly into HTML for the browser, so users always see current data.
  • Filtering, sorting and selecting: xsl:for-each, xsl:sort and xsl:if extract only the needed data from large documents.
  • Integration: it maps data between systems with different XML schemas, such as converting one vendor's format into another's.
  • Declarative and reusable: the transformation is written once as a stylesheet, so no application code needs to change when the output format changes.
  • Standard and widely supported in browsers and server-side processors.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

What is a web server? Describe the various functions and responsibilities performed by a web server.

Answer

A web server is a program (and the computer running it) that accepts HTTP requests from clients such as browsers and sends back responses, usually web pages, images, files or data. It listens on a port (80 for HTTP, 443 for HTTPS). Examples include Apache HTTP Server, Nginx and Microsoft IIS.

Functions and responsibilities

  1. Accepting and processing HTTP requests: it receives requests such as GET and POST, parses them and decides how to answer.
  2. Sending responses: it returns the content with a status code (200 OK, 404 Not Found, 500 Internal Server Error) and headers.
  3. Serving static content: HTML, CSS, JavaScript, images, audio, video and downloadable files.
  4. Serving dynamic content: it hands requests to server-side technologies (PHP, ASP.NET, JSP, Node.js) and returns the generated output.
  5. Security: HTTPS (SSL/TLS), authentication, authorization, access control, and blocking by IP address.
  6. Virtual hosting: one server hosts several websites or domains.
  7. Session and cookie support, helping keep track of users between requests.
  8. Logging and monitoring: access logs and error logs for analysis and troubleshooting.
  9. Handling multiple connections: it serves many clients at once, with caching, compression and load balancing for performance.
  10. URL mapping and redirection: it maps URLs to files or scripts, rewrites URLs and redirects requests.
  11. File upload and download handling, and error pages for failed requests.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 5 marks

Explain how sessions are used in server-side scripting to manage user data. Describe how session data differs from cookies and write server-side script to demonstrate session creation, removal and retrieval.

Answer

Sessions in server-side scripting

A session is a server-side mechanism for remembering information about one user across many HTTP requests. HTTP is stateless, so the server cannot tell by itself that two requests come from the same visitor. When a session starts, the server creates a unique session ID and a storage area (a file, database row or memory) for that visitor. Only the session ID is sent to the browser, normally in a cookie such as PHPSESSID; the real data stays on the server. On each later request the browser returns the ID and the server loads the matching data.

Typical uses are keeping a user logged in, storing the user's name and role, holding a shopping cart, and passing messages between pages (flash messages).

Session vs cookie

BasisSessionCookie
Stored atServer (only the ID is on the client)Client browser
SecurityMore secure, the user cannot read or edit the dataLess secure, the user can view or modify it
SizeLimited by server memory/storageAbout 4 KB per cookie
LifetimeEnds when the browser closes or the session times out or is destroyedLives until its expiry date
Data typesAny data, including arrays and objectsText strings only
UseLogin state, cart, sensitive dataPreferences, "remember me", tracking

PHP script: create, retrieve and remove a session

create.php

<?php
session_start();                       // start or resume session
$_SESSION['username'] = 'ashish';      // create session variables
$_SESSION['role']     = 'student';
echo "Session created. ID: " . session_id();
?>

retrieve.php

<?php
session_start();
if (isset($_SESSION['username'])) {
    echo "Welcome, " . $_SESSION['username'] . " (" . $_SESSION['role'] . ")";
} else {
    echo "No active session. Please log in.";
}
?>

remove.php

<?php
session_start();
unset($_SESSION['role']);              // remove one variable
session_unset();                       // remove all session variables
session_destroy();                     // destroy the session on the server
setcookie(session_name(), '', time() - 3600, '/'); // delete the session cookie
echo "Session removed.";
?>

session_start() must be called before any output is sent, on every page that uses session data.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 10 marks

Write HTML code to create a form for registration of customer data for ecommerce website with field (name, email, phone, address, date of birth, gender) and write server-side code to validate form for required validation for all field, type validation for phone and store that information inside "customers" table within "ecommerce" database.

Answer

(a) HTML registration form (register.html)

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Customer Registration</title>
</head>
<body>
  <h2>Customer Registration</h2>
  <form action="register.php" method="post">
    <label>Name:</label>
    <input type="text" name="name"><br><br>

    <label>Email:</label>
    <input type="email" name="email"><br><br>

    <label>Phone:</label>
    <input type="text" name="phone"><br><br>

    <label>Address:</label>
    <textarea name="address" rows="3" cols="30"></textarea><br><br>

    <label>Date of Birth:</label>
    <input type="date" name="dob"><br><br>

    <label>Gender:</label>
    <input type="radio" name="gender" value="Male"> Male
    <input type="radio" name="gender" value="Female"> Female
    <input type="radio" name="gender" value="Other"> Other<br><br>

    <input type="submit" value="Register">
  </form>
</body>
</html>

(b) Database setup

CREATE DATABASE ecommerce;
USE ecommerce;
CREATE TABLE customers (
  id      INT AUTO_INCREMENT PRIMARY KEY,
  name    VARCHAR(100) NOT NULL,
  email   VARCHAR(100) NOT NULL,
  phone   VARCHAR(10)  NOT NULL,
  address VARCHAR(255) NOT NULL,
  dob     DATE         NOT NULL,
  gender  VARCHAR(10)  NOT NULL
);

(c) Server-side code (register.php)

<?php
$errors = [];

$name    = trim($_POST['name']    ?? '');
$email   = trim($_POST['email']   ?? '');
$phone   = trim($_POST['phone']   ?? '');
$address = trim($_POST['address'] ?? '');
$dob     = trim($_POST['dob']     ?? '');
$gender  = trim($_POST['gender']  ?? '');

// Required validation for all fields
if ($name === '')    $errors[] = "Name is required.";
if ($email === '')   $errors[] = "Email is required.";
if ($phone === '')   $errors[] = "Phone is required.";
if ($address === '') $errors[] = "Address is required.";
if ($dob === '')     $errors[] = "Date of birth is required.";
if ($gender === '')  $errors[] = "Gender is required.";

// Type validation for phone: exactly 10 digits
if ($phone !== '' && !preg_match('/^[0-9]{10}$/', $phone)) {
    $errors[] = "Phone must be numeric and exactly 10 digits.";
}

if (!empty($errors)) {
    foreach ($errors as $e) echo "<p style='color:red'>$e</p>";
    echo "<a href='register.html'>Go back</a>";
    exit;
}

// Store in ecommerce.customers
$conn = new mysqli("localhost", "root", "", "ecommerce");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}

$stmt = $conn->prepare(
  "INSERT INTO customers (name, email, phone, address, dob, gender)
   VALUES (?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssss", $name, $email, $phone, $address, $dob, $gender);

if ($stmt->execute()) {
    echo "Customer registered successfully.";
} else {
    echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
?>

The script first checks that every field is non-empty, then checks the phone with a regular expression so that only digits are accepted. A prepared statement is used for the insert, which prevents SQL injection. If any error is found, nothing is written to the database.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 10 marks

Design and create a responsive webpage using HTML and CSS that includes the following features: (Make necessary assumptions for style information): Header section must contain website logo on the left and include a horizontal navigation menu on the right with at least 4 links.
i. Content section with two columns layouts first part with 80% width which must have A heading(h1) and a paragraph describing the website or product and image with an alt attribute, second part with 20% width contains list of services company provides.
ii. Footer section must contain contact information (address, phone and email) with location map(google) for your company using iframe.
iii. Use semantic tags to define different block of page and navigation must be vertical for width below 756px.

Answer

Responsive webpage using semantic HTML and CSS

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Himal Tech Solutions</title>
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; }

    /* Header: logo left, nav right */
    header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      background: #1f3a5f;
      padding: 10px 20px;
    }
    .logo img { height: 50px; display: block; }
    nav ul { list-style: none; display: flex; }
    nav ul li a {
      display: block;
      color: #fff;
      text-decoration: none;
      padding: 10px 15px;
    }
    nav ul li a:hover { background: #2e5a94; }

    /* Two column content */
    .container { display: flex; }
    main { width: 80%; padding: 20px; }
    main img { max-width: 100%; height: auto; margin-top: 10px; }
    aside { width: 20%; padding: 20px; background: #eef2f7; }
    aside ul { margin-left: 18px; }

    /* Footer */
    footer { background: #222; color: #fff; padding: 20px; }
    footer address { font-style: normal; margin-bottom: 10px; }
    footer iframe { width: 100%; height: 250px; border: 0; }

    /* Vertical nav below 756px (columns stack too) */
    @media (max-width: 756px) {
      header { flex-direction: column; align-items: flex-start; }
      nav { width: 100%; }
      nav ul { flex-direction: column; }
      .container { flex-direction: column; }
      main, aside { width: 100%; }
    }
  </style>
</head>
<body>

  <header>
    <div class="logo">
      <img src="logo.png" alt="Himal Tech logo">
    </div>
    <nav>
      <ul>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>
  </header>

  <div class="container">
    <main>
      <h1>Welcome to Himal Tech Solutions</h1>
      <p>Himal Tech Solutions is a Kathmandu-based software company that builds web and mobile applications, manages cloud hosting and trains students in modern technologies. We help small businesses to move online with reliable, affordable and secure products.</p>
      <img src="office.jpg" alt="Our team working in the Himal Tech office">
    </main>

    <aside>
      <h2>Our Services</h2>
      <ul>
        <li>Web Development</li>
        <li>Mobile Apps</li>
        <li>Cloud Hosting</li>
        <li>IT Training</li>
        <li>SEO</li>
      </ul>
    </aside>
  </div>

  <footer>
    <h3>Contact Us</h3>
    <address>
      Address: New Baneshwor, Kathmandu, Nepal<br>
      Phone: +977-01-4000000<br>
      Email: info@himaltech.com.np
    </address>
    <iframe
      src="https://www.google.com/maps?q=New+Baneshwor,Kathmandu&output=embed"
      title="Company location map"
      loading="lazy"
      allowfullscreen></iframe>
  </footer>

</body>
</html>

Explanation

  • Semantic tags used: header, nav, main, aside, footer and address.
  • The header is a flex container with justify-content: space-between, which puts the logo on the left and the horizontal menu on the right.
  • main takes 80% and aside 20% of the flex row.
  • The viewport meta tag and max-width: 100% on the image make the page responsive.
  • The media query for widths of 756px or less changes the menu to a vertical list and stacks the two columns.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

  • 2025 · 10 marks

Write XML code and create XML Schema Definition (XSD) to validate the structure and data types of the customer XML data. Your schema should enforce the following rules: CustomerID should be a required integer element. Name should be a required string with a maximum length of 100 characters. Phone should be a required string consisting of exactly 10 digits.
Address should be an optional string.
DateOfBirth should be a required date element with a format YYYY-MM-DD.

Answer

(a) XML data (customer.xml)

<?xml version="1.0" encoding="UTF-8"?>
<Customer xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="customer.xsd">
  <CustomerID>101</CustomerID>
  <Name>Ram Bahadur Thapa</Name>
  <Phone>9841234567</Phone>
  <Address>Pokhara, Nepal</Address>
  <DateOfBirth>2000-05-14</DateOfBirth>
</Customer>

(b) XML Schema (customer.xsd)

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">

  <!-- Name: string, max 100 characters -->
  <xs:simpleType name="NameType">
    <xs:restriction base="xs:string">
      <xs:maxLength value="100"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- Phone: exactly 10 digits -->
  <xs:simpleType name="PhoneType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-9]{10}"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="Customer">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="CustomerID"  type="xs:integer"/>
        <xs:element name="Name"        type="NameType"/>
        <xs:element name="Phone"       type="PhoneType"/>
        <xs:element name="Address"     type="xs:string" minOccurs="0"/>
        <xs:element name="DateOfBirth" type="xs:date"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>

How the rules are enforced

  • Elements are required by default (minOccurs="1"), so CustomerID, Name, Phone and DateOfBirth must appear. Address has minOccurs="0", so it is optional.
  • CustomerID uses xs:integer, so a value like abc is rejected.
  • Name restricts xs:string with maxLength 100.
  • Phone restricts xs:string with the pattern [0-9]{10}, which allows exactly ten digits and nothing else.
  • DateOfBirth uses xs:date, whose lexical form is YYYY-MM-DD, so 2000-05-14 is valid and 14/05/2000 is not.
  • xs:sequence forces the elements to appear in the order given.

Answer checked by Claude Sonnet · Oct 21, 2026

Test yourself · 2 MCQs

Loading…

Questions from TU BCA 2019 Third Semester Data Structures and Algorithms (TU board exam, 2019), TU BCA 2019 Third Semester Data Structures and Algorithms (TU board exam, 2019 Group A objective questions (scanned paper compiled by Aadim College)), TU BCA 2020 Third Semester Data Structures and Algorithms (TU board exam, 2020), TU BCA 2021 Third Semester Data Structures and Algorithms (TU board exam, 2021), TU BCA 2022 Third Semester Data Structures and Algorithms (TU board exam, 2022), TU BCA 2023 Third Semester Data Structures and Algorithms (TU board exam, 2023), TU BCA 2024 Third Semester Data Structures and Algorithms (TU board exam, 2024), TU BCA 2025 Third Semester Data Structures and Algorithms (TU board exam, 2025), TU BCA 2019 Third Semester OOP in Java (TU board exam, 2019), TU BCA 2019 Third Semester OOP in Java (TU board exam, 2019 Group A objective questions (scanned paper compiled by Aadim College)), TU BCA 2020 Third Semester OOP in Java (TU board exam, 2020), TU BCA 2021 Third Semester OOP in Java (TU board exam, 2021), TU BCA 2022 Third Semester OOP in Java (TU board exam, 2022), TU BCA 2023 Third Semester OOP in Java (TU board exam, 2023), TU BCA 2024 Third Semester OOP in Java (TU board exam, 2024), TU BCA 2025 Third Semester OOP in Java (TU board exam, 2025), TU BCA 2019 Third Semester Probability and Statistics (TU board exam, 2019), TU BCA 2019 Third Semester Probability and Statistics (TU board exam, 2019 Group A objective questions (scanned paper compiled by Aadim College)), TU BCA 2020 Third Semester Probability and Statistics (TU board exam, 2020), TU BCA 2021 Third Semester Probability and Statistics (TU board exam, 2021), TU BCA 2022 Third Semester Probability and Statistics (TU board exam, 2022), TU BCA 2023 Third Semester Probability and Statistics (TU board exam, 2023), TU BCA 2024 Third Semester Probability and Statistics (TU board exam, 2024), TU BCA 2025 Third Semester Probability and Statistics (TU board exam, 2025), TU BCA 2019 Third Semester System Analysis and Design (TU board exam, 2019), TU BCA 2019 Third Semester System Analysis and Design (TU board exam, listed as 2019 (a second 2019 set in the compilation)), TU BCA 2019 Third Semester System Analysis and Design (TU board exam, 2019 Group A objective questions (scanned paper compiled by Aadim College)), TU BCA 2020 Third Semester System Analysis and Design (TU board exam, 2020), TU BCA 2021 Third Semester System Analysis and Design (TU board exam, 2021), TU BCA 2022 Third Semester System Analysis and Design (TU board exam, 2022), TU BCA 2023 Third Semester System Analysis and Design (TU board exam, 2023), TU BCA 2024 Third Semester System Analysis and Design (TU board exam, 2024), TU BCA 2025 Third Semester System Analysis and Design (TU board exam, 2025), TU BCA 2019 Third Semester Web Technology (TU board exam, 2019), TU BCA 2019 Third Semester Web Technology (TU board exam, 2019 Group A objective questions (scanned paper compiled by Aadim College)), TU BCA 2020 Third Semester Web Technology (TU board exam, 2020), TU BCA 2021 Third Semester Web Technology (TU board exam, 2021), TU BCA 2022 Third Semester Web Technology (TU board exam, 2022), TU BCA 2023 Third Semester Web Technology (TU board exam, 2023), TU BCA 2024 Third Semester Web Technology (TU board exam, 2024) and TU BCA 2025 Third Semester Web Technology (TU board exam, 2025). Answers are written for this site; check them against your class notes.