0% found this document useful (0 votes)
3 views32 pages

Computer

The document provides an overview of Database Management Systems (DBMS) and networking concepts, including SQL commands for creating tables and inserting data, the relational database model, roles of a Database Administrator, and types of data integrity. It also discusses network topologies, communication media, and the differences between LAN and WAN. Additionally, it explains wireless networks and the necessary devices for Wi-Fi connectivity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views32 pages

Computer

The document provides an overview of Database Management Systems (DBMS) and networking concepts, including SQL commands for creating tables and inserting data, the relational database model, roles of a Database Administrator, and types of data integrity. It also discusses network topologies, communication media, and the differences between LAN and WAN. Additionally, it explains wireless networks and the necessary devices for Wi-Fi connectivity.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

Computer

Database Management System (DBMS)

1. Write SQL DDL commands to execute the following task with reference to
the schema given below.
 Creating the table with primary key and not null constraints:
CREATE TABLE student info ( regno INTEGER PRIMARY KEY, name CHAR(25)
NOT NULL, class INTEGER NOT NULL, gender CHAR(1) NOT NULL, address
CHAR(25),
);
2. Define a syntax for database connectivity.
Write a server-side scripting code to insert data into the table student having
fields (first name, last name, mark, and email). Assume:
Server name = "localhost"
Username = "root"
Password = ""
Database name = "student DB"
 Database Connectivity Syntax (PHP - MySQLi)
Database Connectivity Syntax (PHP - MySQLi)
 <?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "student_DB";

// Create connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

 Server-Side Scripting Code to Insert Data


 <?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "student_DB";
// Create connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

// SQL to insert data


$first_name = "John";
$last_name = "Doe";
$mark = 85;
$email = "[email protected]";

$sql = "INSERT INTO student (first_name, last_name, mark, email)


VALUES ('$first_name', '$last_name', '$mark', '$email')";

if ($conn->query($sql) === TRUE) {


echo "New record inserted successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

// Close connection
$conn->close();
?>


3. Explain the Relational Database Model.
 Relational database model uses tables (relations) to store data. Each table
consists of rows (records) and columns (attributes). Relationships between
tables and established through foreign keys.
Advantages: Simple to use, highly flexible, and widely adopted. SQL is used
to manage and query relational databases.
Disadvantages: Can become ine icient with very large datasets and complex
query.
4. Demonstrate any two DDL statements with an example.
 Data Definition Language (DDL) commands are used to define and manage
database structures.
a. CREATE TABLE
CREATE TABLE Customers (
CustomerID INT PRIMARY KEY,
Name VARCHAR(100),
Email VARCHAR(100)
);
b. ALTER TABLE
ALTER TABLE Customers (
ADD PhoneNumber VARCHAR(15);
);
5. What are the roles of the Database Administrator (DBA)? Describe.
 A database administrator (DBA) is responsible for managing, maintaining,
and securing databases. Key roles of database administrator include:
a. Installation and Configuration: Setting up database servers and
configuring databases.
b. Performance monitoring and turning: Ensuring databases perform
e iciently by optimizing queries and managing resources.
c. Backup and Recovery: Implementing backup strategies and restoring data
in case of loss.
d. Security Management: Controlling access to data, implementing security
policies, and protecting against unauthorized access.
e. Maintenance and Upgrades: Performing regular maintenance and
upgrading database software as needed.
f. Data integrity: Ensuring accuracy and consistency of data within the
database.
6. Describe the DDL statement with an example in SQL.
 DDL is sometimes known as Data Description Language since its statements
can also be used to describe, comment on and place labels on database
objects.
DDL commands: CREATE, ALTER, DROP
Exampale:
CREATE TABLE Orders (
OrderDate DATE,
CustomerID INT,
Amount DECIMAL(10,2)
);
7. Di erentiate between centralized and distributed database systems.
Centralized Distributed database system
It is a database that is stored, It is a database that is spread across
located as well as maintained at a di erent physical locations.
single location only.
The data access time in the case of The data access time in the case of
multiple users is more in a multiple users is less in a
centralized database. distributed database.
The users cannot access the In a distributed database, if one
database in case of database failure database fails, users have access to
occurs. other databases.
A centralized database is less This database is very expensive.
costly.
It is easy to maintain the data and It is di icult to maintain because of
information is available at a single the distribution of data and
location. information at varied places.

8. Explain di erent database models with suitable examples.


 Hierarchical model
S hierarchical database is a data model in which data is stored in the form of
records and organized into a tree-like structure, or parent-child structure, in
which one parent node can have many child nodes connected through links.
Advantages: Simple design, e icient for one-to-many relationships.
Disadvantages: Lack of flexibility, complex management of many-to-many
relationships.
 Network model
The network model is a representation of the nodes on the network and
certain characteristics of the network itself.
Advantages: Flexible, supports many-to-many relationships.
Disadvantages: complex design and implantation, requires sophisticated
management tools.
9. Explain the Relational Data model with example.
 The relational model represents how data is stored in relational databases. A
relational database consists of a collection of tables, each of which is
assigned a unique name. Let us consider a relation STUDENT with attributes
ROLL_NO, NAME, ADDRESS, PHONE, and AGE shown in the table.
Relation Name: Student
ROLL_NO NAME ADDRESS PHONE AGE
1 Bipin K.C. Syangja 9855123457 25
2 Sonee Khatri Phokhara 9852431546 24
3 Nawadeep Kathmandu 9856253135 20
K.C.
4 Robin Roka Arjunchoupari 9762531314 22

10. Explain entity, attribute, and relationship in a Relational Database
Management System.
 Entities: Objects or things in the databases ( e.g. Students, Courses ).
 Attributes: Properties of entities ( e.g. StudentID, Name).
 Relationships: Associations between entities (e.g., Student enrolls in a
Course).
11. What is the importance of normalization in DBMS? Explain.
 Normalization is a process in DBMS that organizes data to eliminate
redundancy and ensure data integrity. It involves dividing large tables into
smaller ones and defining relationships between them.
Importance of Normalization:
 Eliminates Data Redundancy: Prevents duplicate data storage, reducing
storage costs.
 Ensures Data Integrity: Reduces inconsistencies by keeping data in one
place.
 Improves Data Access & Query Performance: Smaller, well-structured tables
improve query speed.
 Avoids Anomalies: Prevents insertion, update, and deletion anomalies.
 Ensures Scalability & Flexibility: Makes it easier to modify the database
without a ecting other tables.
12. Explain the di erent types of data integrity in DBMS.
 Data integrity states to the accuracy, consistency, and reliability of data
stored in a database or a data storage system. It ensures that data remains
unaltered during operations such as transfer, storage, and retrieval.
Types of Data Integrity
a. Entity integrity: it ensures that each entity (eg. Table row) is uniquely
identifiable. Primary keys are used to enforce entity integrity.
b. Referential integrity: Referential integrity ensures that relationships
between tables. Foreign keys are used to maintain referential integrity
among the tables.
c. Domain integrity: Domain integrity ensures that all entries in a column fall
within a defined set of permissible values.

Importance of data integrity in database design

a. Accuracy: Accurate data is essential for decision-making processes.


b. Consistency: Consistent data across the database prevents
discrepancies that could cause confusion and errors in data processing
and analysis.
c. Reliability: Reliable data ensures that the system can be trusted by its
users, fostering user confidence and reliability.
d. E iciency: Maintaining data integrity helps in optimizing system
performance and reducing errors during data manipulation.
13. Data Security:
 Data Security refers to the protection of data from unauthorized access
corruption, or theft. It encompasses various practices and technologies
designed to safeguard sensitive information.
Its importance in a database includes:
Preventing unauthorized access: Ensures that only authorized users can
access and manipulate the data.
Data integrity: Protects data from corruption and ensures that it remains
accurate and consistent.
Compliance with regulations: Helps organizations comply with laws and
regulations related to data privacy, such as GDPR or HIPAA.
Building trust: Enhances the trust of customers and stakeholders by
ensuring that their data is secure.
Preventing data breaches: Minimizes the risk of data breaches that could
lead to financial loss and reputational damage.

Networking

1. Describe the class C IP address with an example.


 An IP Address is a unique address that identifies a device on the internet or a
local network. There are two IP versions: IPv4 and IPv6. IPv4 is the older
version which has a space of over 4 billion IP addresses. Example:
172.16.254.1 in IPv4.
2. Compare the star and ring topology. Include their features, pros, and cons.
Star Topology Ring Topology
In star topology, central hub is used In ring topology, circular loop
with individual connections to each structure is used with each device
device. connected to two others.
It is easy to install and manage. It is comparatively more complex in
installation and maintenance.
The failure of hub a ects the entire The failure of a single device can
network. disrupt the entire network.
It is easy to add new devices. Adding/ removing devices can disrupt
the network.
It has high performance, and reduced It has high-speed of data
collisions. transmission, and minimal collisions.
The cost goes higher due to more Potentially the cost is lower due to
cabling and the cost to the hub. fewer cables but depends on
redundancy setup.
The fault isolation is easier. The isolation is complex.
Since it is centralized, it can become Since it has equal access, it is
a bottleneck. sensitive to failures.

3. Explain coaxial cables and fiber optic cables.


 A cable with a central conductor surrounded by insulation and a metallic
shield to minimize interference.
Uses: Used for cable TV, Broadband internet, and LAN.
Advantages: Better shielding reduces EMI (Electromagnetic interference).
Inexpensive for short-distance communication.
Disadvantages: Limited bandwidth. Signal loss over long distances.
 A cable that transmits data using light signals through glass or plastic fibers.
Uses: High speed internet, long distance communication.
Advantages: High bandwidth and speed. Immune to EMI. Supports long-
distance communication with minimal signal loss.
Disadvantages: Expensive to install. Fragile compared to other cables.
4. What is a computer network? List hardware requirement.
 A computer network is a system where two or more computer or devices are
interconnected to share resources, data and communication.
Necessary equipment
Router: Connects di erent networks and manages data tra ic.
Switch: Connects multiple devices int the same network.
NIC: Allows devices to communicate with the network.
Cables: Physical medium for data transfer.
Access Point: Provides wireless connectivity.
5. Di erentiate between LAN and WAN. Explain their characteristics. (5)
LAN WAN
Limited to a small area like a building Covers large geographical areas, like
or campus. countries or continents.
High speed (typically up to 1 Gbps). Lower speed (typically up to 100
Mbps.)
Usually owned and maintained by a Owned by multiple organization or
single organization. lazed from service providers.
Lower error rates. Higher error rates.
Lower setup and maintenance costs. Higher setup and maintenance costs.

6. Describe the types of communication media used in networking. (5)


 Communication media refers to the medium used for transmitting data
between devices in a network.
 Bounded/Guided media: Use physical cables to transmit data. Examples:
a. Twisted pair cable (used in LAN).
b. Coaxial cable (used in TV and internet).
c. Fiber optics cable (used for high-speed communication).
 Unbounded/Unguided media: Transmits data wirelessly. Examples:
a. Radio wave (used in Wi-Fi, mobile communication).
b. Microwaves (used in satellite communication).
c. Infrared (used in remote controls).
7. Define network topology. Explain the Ring Topology in detail with a diagram.
(2+3)
 Network topology refers to the arrangement of devices in a network, defining
how they are connected and how data flows. In other words, the physical and
logical arrangement of nodes and connections in a network is called a
network topology.
Types of network topology
Bus Topology: All devices are connected to a single central cable.
Advantages: Low-cost cable, moderate data speeds, simple-easy to
implement, limited failure.
Disadvantages: Extensive cabling, Di icult troubleshooting, signal
interference, reconfiguration di icult, attenuation.
Ring Topology: Devices are connected in a circular fashion, and data travels
in one direction around the ring.
Advantages: E icient for small networks, low cost, Reliable.
Disadvantages: Di icult troubleshooting, Failure, Reconfiguration di icult,
Delay.
Star Topology: All devices are connected to a central device (hub or switch).
Data is sent through the central device to other devices.
Advantages: E icient troubleshooting, Failure of one device doesn’t a ect
the rest of the network, Limited failure, easily expandable, cost e ective.
Disadvantages: Failure of a central point a ect entire network, some time
cabling di icult, Speed can be degraded if the no. of devices where increase.
8. What is a wireless network system? List the devices and equipment necessary
for a Wi-Fi network. (3+2)
 A wireless network transmits data using radio waves or infrared signal
without the need for cables. Wireless networks are flexible and allow user to
connect to the internet or local network from virtually anywhere within the
network range.
Devices for a Wi-Fi network:
Router: Connects devices to the internet wirelessly.
Access Point: Extends the Wi-Fi range.
Wi-Fi Adapters: Hardware in devices such as laptops, desktops, and printers
to enable wireless connectivity.
9. What is the di erence between bounded and unbounded transmission
media? (5)
Guided media Unguided media
Guided media are the physical cables Unguided media uses
(e.g. twisted pair, coaxial fiber optics) electromagnetic waves (e.g. radio,
microwave, infrared).
Setting guided media is more It is easier as it involves in setting up
complex and requires laying of antennas or transmitters.
cables.
The are coverage is limited, devices The are coverage is high, devices can
need to be connected by cables. be moved freely within the range.
Guided media is less susceptible to Unguided media is more susceptible
interference. to environmental interference.
Generally, it is more secure due to It is less secure, and can be
physical connections. intercepted more easily without
proper encryption.
It is limited by the length of cables; It can cover vast distances (e.g.
requires repeaters for long distances. satellite communication) but also
depends on the technology used.

10. Di erentiate between peer-to-peer and client/server networks. (5)


Client-server network Peer-to-Peer network
In a client-server network, we have a Clients are not distinguished in a
server and clients that are peer-to-peer network; every node
connected to the server. serves as client and server.
A client-server network is more Peer-to-peer networks become less
stable and scalable than a peer-to- stable and scalable as the number
peer network. of peers in the system grows.
A client-server network is secure As the number of peers increases,
because the server can validate a the network’s security deteriorates,
client’s access to any network area. and its vulnerability grows.
When many customers make A sever is not bottlenecked because
simultaneous service requests, a services are distributed across
server may become overloaded. multiple servers via a peer-to-peer
network.

11. What is transmission media? Explain any two types of transmission media.
 The physical or wireless path through which data is transmitted (eg. Cables,
fiber optics, radio waves).
 Coaxial cable: The core is made up of copper conductors. Its purpose is the
signal transmission. To prevent unwanted interference, a metal conductor is
braided around the insulator.
 Fiber Optics: Fiber optics fibers are transparent, flexible wires composed of
glass or plastic that are just a little thicker than a human hair. It acts as a
waveguided, allowing light to travel between the fiber’s two ends.
12. What is optical fiber cable in networking? Discuss its advantages. (5)
 Fiber optic cable transmits data as light pulses through or plastic fibers,
o ering high bandwidth and long-distance communication
Advantages: High bandwidth and speed, Immune to EMI, supports long-
distance communication with minimal signal loss.
Disadvantages: Expensive to install, Fragile compared to other cables.
13. What is network architecture?
14. Network architecture refers to the design and structure of a computer network,
including its physical and logical aspects. It outlines how devices and resources
are organized and how data is flows between them.
15. Explain the OSI/ISO model of networking. (7)
 The OSI (Open Systems Interconnection) model is a conceptual framework that
standardizes the functions of communication systems into seven distinct
layers. Each layer is responsible for special tasks in the communication
process.
 Physical Layer: Responsible for the physical connection between devices
and the transmission of raw data bits over a medium (cables, wireless).
Example: Cables, switches.
 Data Link Layer: Ensures error-free data transfer and manages physical
addressing (MAC addresses).
Example: Ethernet, Wi-Fi.
 Network Layer: Handles logical addressing (IP addresses) and routing of data
across networks.
Example: Routers.
 Transport Layer: Ensures reliable data transfer and error correction between
devices.
Example: TCP, UDP.
 Session Layer: Manages and controls the dialog (session) between two
devices.
Example: NetBIOS, RPC.
 Presentation Layer: Translates, compresses, and encrypts data. Ensures that
data is in a readable format.
Example: SSL, JPEG, ASCII.
 Application Layer: Provides network services to end-user applications.
Example: HTTP, FTP, SMTP.
16. What is networking? Discuss its advantages and disadvantages. (2.5+2.5)]
 Networking refers to the practice of connecting multiple devices to exchange
data and share resources like files and printers.
Advantages: Resource sharing, centralized data management, communicate
to anyone from anywhere in network range, cost e ective.
Disadvantage: Security risks, complexity, high setup cost, maintenance.
17. What are the di erent types of LAN topologies? Explain with diagrams. (5)
 Local Area Network is a network that connects computers and devices within
a limited geographical area, such as a home, o ice, or building. Bus topology,
Star topology, Ring Topology.
Web Technology

1. Write a JavaScript code to calculate the factorial of a given number.


 const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question("Enter a number: ", function(a) {


a = parseInt(a);
let fact = 1;

if (a === 0 || a === 1) {
console.log("The factorial of given number is 1");
} else {
for (let b = 2; b <= a; b++) {
fact *= b;
}
console.log("The factorial of given number is " + fact);
}

rl.close();
});
2. Write a JavaScript function to add two numbers and return the sum.
const readline = require('readline');

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});

rl.question("Enter first number: ", function (num1) {


rl.question("Enter second number: ", function (num2) {
let a = Number(num1); // Convert input to number
let b = Number(num2); // Convert input to number

if (isNaN(a) || isNaN(b)) {
console.log("Please enter valid numbers.");
} else {
console.log(`The sum is: ${sum(a, b)}`);
}

rl.close(); // Close the interface


});
});

function sum(a, b) {
return a + b;
}
3. Explain the database connection method in PHP.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "my_database";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $database);

// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}

echo "Connected successfully";


?>
4. How do you fetch data from a database in PHP and display it in a form?
Describe.
<?php
$conn = new mysqli("localhost", "root", "", "test_db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
?>
<?php
$id = $_GET['id']; // Get ID from URL
$sql = "SELECT * FROM users WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
$row = $result->fetch_assoc();
?>
<form method="POST" action="update.php">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>">

<label>Name:</label>
<input type="text" name="name" value="<?php echo $row['name']; ?>"><br>

<label>Email:</label>
<input type="email" name="email" value="<?php echo $row['email']; ?>"><br>

<button type="submit">Update</button>
</form>
5. Write short notes on Internet technology.
 Internet technology refers to the infrastructure, protocols, and systems that
enable communication and access to data over the internet. Key aspects
include:
Protocols: These define how data is transmitted over the internet. Examples
include HTTP, TCP/IP, FTP,
Web Browsers: Software application (e.g. Chrome, Firefox) used to access
websites.
Web servers: Hardware/ software system that store and serve web pages.
HTML, CSS, JavaScript: Technologies used to create and design websites.
Cloud computing: Allows storing and accessing data on remote servers over
the internet.
6. Di erentiate between server-side and client-side scripting.
Server-side Scripting Client=side Scripting
Executes on the web server. Executes on the user’s browser.
Used for database interaction, Used for user interface and
processing form data etc. enhancing user experience.
Examples: PHP, Node.js, Python Example: JavaScript, HTML, CSS
Can interact with databases and file Cannot directly interact with server
systems. resources.
Examples of languages: PHP, Java, Examples of languages: JavaScript,
Ruby, Python. HTML, CSS.

7. Explain di erent data types used in JavaScript.


 Number: represents both integer and floating-points numbers.
Example: let num = 100;
String: Represents a sequence of characters.
Example: let name = “john”;
Boolean: Represents true or false.
Example: let isActive = true;
Objects: Stores collection of data as key-value pairs.
Example: let person = { name: ”john”, age 30};
Array: A special type of object that stores ordered collections.
Example: let fruit = [ “Apple”, “Banana”, “Orange”]
Undefined: Indicates that a variable has not been assigned a value.
Example: let age;
Null: Represents the intentional absence of any objects value.
Example: let user = null;
8. What is jQuery? Write down its uses.
 JQuery is a fast, small, and feature-rich JavaScript library. It simplifies tasks
like HTML document traversal and manipulation, event handling, animations,
and AJAZ with an easy-to-use API that works across a multiple of browsers.
DOM manipulation: you can select, modify, and animate HTML elements
easily.
Event handling: Handling events like clicks, mouse movements. Etc.
AJAX support: Simplifies making asynchronous HTTP requests.
Cross-browser compatibility: Ensures that your code works on all browsers.
9. What is PHP? Explain its uses and advantages.
 Hypertext preprocessor is a server-side scripting language primarily used for
web development.
Uses
Server-side scripting for dynamic web pages.
Database interaction to store/ retrieve data.
Can be embedded within HTML to generate dynamic content.
Advantages
Open source: Free to use.
Cross platform: Works on multiple operating system.
Ease of use: Easy to learn and implement.
Integration: Easily integrates with databases, especially MySQL.
10. Write the basic PHP syntax and provide an example of a PHP program.
 Basic PHP syntax:
PHP code starts with <?php and ends with ?>.
Variables in PHP are prefixed with $.
PHP statements end with a semicolon(;).
Example:
<?php
// This is single line comment.
/* This is multiline comment.
*/
$name = “john Doe”; //Declaring a variable.
echo = “Hello, $name!”; // printing in console.
11. Explain the different operators used in PHP.
a. Arithmetic operators: +, -, *, /, % **.
$a = 10;
$b =3;
echo $a + $b;
b. Assignment operators: =, +=, -=, *=, /=, %=.
$a = 10;
$a += 5;
echo $a;
c. Comparison operators: ==, ===, !=, !==, >, <, >=, <=.
$a = 10;
$b = 5;
var_dump($a>$b);
d. Logical operators: &&, ||, !, xor.
$a = true.
$b = false.
var_dump($a && $b);
e. Increment/Decrement Operators: ++, --
$a = 10;
$a++;
f. String operators: .(Concatenation), = (Concatenation assignment).
$str1 = “Hello”;
$str2 = “World”;
echo $str1.$str2;
12. Write a PHP program to display the largest among three numbers.
<?php
// Define the three numbers
$num1 = 10;
$num2 = 25;
$num3 = 15;

// Find the largest number


if ($num1 >= $num2 && $num1 >= $num3) {
echo "The largest number is: " . $num1;
} elseif ($num2 >= $num1 && $num2 >= $num3) {
echo "The largest number is: " . $num2;
} else {
echo "The largest number is: " . $num3;
}
?>
13. What are the uses of JavaScript in web page development.
 Uses of JavaScript in Web Page Development:
Dynamic Content: JavaScript is used to create dynamic and interactive web
pages. It can update HTML content without reloading the page.
Form Validation: It helps in validation forms before sending data to the server,
reducing the need for server-side checks.
Event Handling: JavaScript is used to handle events like clicks, mouse
movements, and keyboard inputs.
AJAX: JavaScript allows for asynchronous data fetching without reloading the
page, leading to a smoother user experience.
Animations and E ects: JavaScript helps in creating animations, transitions,
and other visual e ects.
14. ? How do you connect PHP with a MySQL database? Explain with a
connection class.
<?php
class Database {
private $host = 'localhost';
private $username = 'root';
private $password = '';
private $database = 'test_db';
public $conn;
public function __construct() {
$this->conn = new mysqli($this->host, $this->username, $this-
>password, $this->database);
if ($this->conn->connect_error) {
die("Connection failed: " . $this->conn->connect_error);
}
}
public function close() {
$this->conn->close();
}
}
$db = new Database();
echo "Connected successfully";

$db->close();
?>

15. What is object-based programming? Explain di erent JavaScript objects.


 Object-based programming refers to programming paradigms where the
primary focus is on the creation of objects. Unlike traditional procedural
programming, objects in this paradigm are instances of classes and
encapsulate both data and behaviour. JavaScript is often considered an
object-based language, even though it doesn’t support full object-oriented
concepts like inheritance.
 Di erent JavaScript Objects.
a. Math Object: Provides properties and methods for mathematical
constants and functions.
Example: Math.(5,10,15) returns the highest value.
b. Date Object: Used to work with dates and times.
Example: let today = new Date();
c. String Object: Provides methods to manipulate and work with strings.
Example: “Hello”.toUpperCase() converts the string to uppercase.
d. Array Object: Represents a collection of values and provides methods to
manipulate them.
Example: let arr = [ 1,2,3]; arr.push(4); adds an element to the array.
e. Window Object: Represents the browser window and provides methods
for browser-specific functions.
Example: window.alert(“Hello World”); displays an alert box.

16. Write a server-side script to create a database, connect with it, create a
table, and insert data into it.

<?php

$server = "localhost";

$username = "root";

$password = "";

$conn = new mysqli($server, $username, $password);

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);

$dbName = "my_database";

$sql = "CREATE DATABASE IF NOT EXISTS $dbName";

if ($conn->query($sql) === TRUE) {

echo "Database created successfully<br>";


} else {

echo "Error creating database: " . $conn->error;

$conn->select_db($dbName);

$tableSQL = "CREATE TABLE IF NOT EXISTS users (

id INT AUTO_INCREMENT PRIMARY KEY,

name VARCHAR(50) NOT NULL,

email VARCHAR(50) UNIQUE NOT NULL,

age INT NOT NULL

)";

if ($conn->query($tableSQL) === TRUE) {

echo "Table 'users' created successfully<br>";

} else {

echo "Error creating table: " . $conn->error;

$insertSQL = "INSERT INTO users (name, email, age) VALUES

('John Doe', '[email protected]', 25)";

if ($conn->query($insertSQL) === TRUE) {

echo "Data inserted successfully<br>";

} else {

echo "Error inserting data: " . $conn->error;

$conn->close();

?>

Programming in C

1. Define the term constant, variable, identifier.


 Constant: A constant is a fixed value that does not change during program
execution.
Example: π = 3.1416, gravity = 9.8
 Variable: A variable is a memory location that stores data and can change
during program execution.
Example: int age = 25;, float temperature = 36.5;
 Identifier:
An identifier is the name used to identify variables, constants, functions, or
classes in a program.
Example: sum, studentName, totalMarks

2. What is a user-defined function? What are its advantages? Write a C program


to add two numbers using a function.
 A user-defined function in C is a function that the programmer defines to
perform a specific task, rather than using built-in functions like printf() or
scanf().
Advantages:
 Code Reusability – Functions can be reused multiple times, reducing
redundancy.
 Modular Programming – Breaks the program into smaller, manageable parts.
 Improves Readability – Makes the code easier to understand.
 Easier Debugging – Errors can be isolated and fixed in specific functions.
 E icient Memory Usage – Reduces memory usage by avoiding repeated code.
Example:
#include <stdio.h>
int add(int a, int b) {
return a + b;
}
int main() {
int num1, num2, sum;
printf("Enter two numbers: ");
scanf("%d %d", &num1, &num2);
sum = add(num1, num2);
printf("Sum = %d\n", sum);
return 0;
}
3. What is a pointer? Explain its advantages with an example.
 A pointer is a variable that stores the memory address of another variable.
Instead of holding a direct value, a pointer holds the location where the value
is stored.
Advantages:
 E icient Memory Access – Directly accesses memory locations.
 Dynamic Memory Allocation – Enables memory management using malloc(),
free(), etc.
 Pass by Reference – Allows functions to modify actual variables.
 Data Structures – Used in linked lists, trees, etc.
 Array and String Handling – Simplifies complex operations.
Example:
#include <stdio.h>
int main() {
int num = 10;
int *ptr = &num; // Pointer storing address of num
printf("Value of num: %d", *ptr);
return 0; }
4. What is a string function? Write a program to concatenate two strings.
 A string function in C is a function that performs operations on strings, such
as copying, concatenation, length calculation, comparison, etc.
Example Program to Concatenate Two Strings:
#include <stdio.h>
#include <string.h>
int main() {
char str1[50] = "Hello, ";
char str2[50] = "World!";
strcat(str1, str2); // Concatenates str2 to str1
printf("Concatenated String: %s", str1);
return 0;
}
5. What is file handling in C? Explain with an example and mention its advantages.
 File handling in C refers to reading from and writing to files using functions
like fopen(), fclose(), fprintf(), fscanf(), etc. It allows storing data permanently
instead of using temporary memory (RAM).
Advantages:
 Permanent Storage: Data remains available even after program termination.
 E icient Data Handling: Large amounts of data can be stored and retrieved
easily.
 Data Security: Prevents data loss compared to volatile memory.
 Flexibility: Supports di erent file modes (read, write, append, etc.).
Example:
#include <stdio.h>
int main() {
FILE *file = fopen("example.txt", "w"); // Open file in write mode
if (file == NULL) {
printf("Error opening file!");
return 1;
}
fprintf(file, "Hello, File Handling in C!"); // Writing to file
fclose(file); // Closing the file
printf("Data written successfully!");
return 0;
}
6. Explain recursion in C with an example.
 Recursion is a programming technique where a function calls itself directly or
indirectly to solve a problem.
Advantages:
 Simplifies complex problems by breaking them into smaller subproblems.
 Reduces code length compared to iterative approaches.
 Useful for tree and graph-based problems.
Example:
#include <stdio.h>
int factorial(int n) {
if (n == 0)
return 1;
return n * factorial(n - 1);
}
int main() {
int num = 5;
printf("Factorial of %d is %d", num, factorial(num));
return 0;
}
7. Di erentiate between library and user-defined functions.
Library Functions User-Defined Functions
Predefined functions in C Functions created by the programmer.
standard libraries.
Already available in C (stdio.h, Must be defined explicitly in the program.
math.h, etc.).
printf(), scanf(), sqrt(), strlen(). int add(int a, int b), void display().
Simple to use, no need to Requires defining the logic before use.
define logic.
Faster (precompiled and Slightly slower as they need to be compiled.
optimized).

8. Di erentiate between array and structure.


Structure in C Array in C
A structure is a data structure that An array in a data structure that can
can contain variables of di erent data only contain variables of the same
types. data type.
Structures do not require the data to Arrays store data in contiguous
be stored in consecutive memory memory locations, meaning that
locations. memory blocks are assigned
consecutively.
Toi access elements in a structure, In arrays, elements can be accessed
the name of the specific element is by their index.
required.
Structure can be slower to search and Arrays can be faster to search and
access due to the presence of access due to the absence of multiple
multiple data types. data types.
Elements in a structure can be of Elements in an array are always of the
di erent sizes. same size.

9. Explain structure in C with an example.


 A structure in C is a user-defined data type that allows grouping di erent
data types together under a single name.
Syntax:
struct StructureName {
dataType member1;
dataType member2;
};
Example:
#include <stdio.h>
struct Person {
char name[50];
int age;
float height;
};
int main() {
struct Person person1;
person1.age = 25;
person1.height = 5.9;
strcpy(person1.name, "John");
printf("Name: %s\n", person1.name);
printf("Age: %d\n", person1.age);
printf("Height: %.2f\n", person1.height);
return 0;
}
10. Describe the function in C. Write a program to find the sum of two numbers
using a function.
A function is a self-contained block of code that performs a specific task. It
can be called from other parts of the program to execute the code defined in
it.
Advantages:
Modularity: Breaks the program into smaller, manageable parts.
Reusability: Code can be reused by calling the function multiple times.
Abstraction: Hides the implementation details and exposes only the
functionality.
Maintainability: Easier to maintain and update the code.

Object oriented programming

1. How does event-driven programming (or OOP) di er from procedural-


oriented programming? Explain.
Procedural Oriented programming Object-oriented programming
In procedural programming, the In object-oriented programming, the
program is divided into small parts program is divided into small parts
called functions. called objects.
Procedural programming follows a Object-Oriented programming
top-down approach. follows a bottom-up approach.
Adding new data and function is not Addin new data and functions is
easy. easy.
In procedural programming, there is In object-oriented programming, the
no concept of data hiding and concept of data hiding and
inheritance. inheritance is used.
Code reusability is absent in Code reusability is present in
procedural programming. object-oriented programming.

2. Write the advantages of OOPs.


 OOP is a programming paradigm that uses “Objects” to design and develop
applications.
Advantages:
Reusability: code can be reused through inheritance, reducing redundancy.
Scalability: Easier to manage and scale large codebases due to modularity.
Maintenance: Enhances code maintainability and modification.
Productivity: Encourages a more structured approach to programming,
improving productivity.
Flexibility: Allows for easy modification and extension of code.
Disadvantages:
Performance: Object-Oriented programs can be slower due to the overhead
of abstraction and encapsulation.
Complexity: OOP can introduce additional complexity compared to
procedural programming.
Larger memory usage: OOP programs consume more memory due to
objects, pointers, and dynamic binding.
Characteristics (features)
Encapsulation : Encapsulation involves bundling data and methods that
operate on the data into a single unit or class.
Inheritance: is a mechanism, where a new class inherits attributes and
methods form an existing class.
Polymorphism: The ability of di erent classes to be treated as instance of the
same class through a common interface. It allows methods to be used in
di erent ways based on the object’s class.
Abstraction: Data abstraction is the process of hiding the complex
implementation details and showing only the essential features of an object.
Applications:
Software Development: Used in creating desktop applications, such as
Microsoft O ice and Adobe software.
Web Development: Frameworks like Django (Python) and Spring (Java) use
OOP concepts.
Game Development: Engines like Unity and Unreal Engine use OOP
principles.
Mobile Application Development: Android and iOS apps are built using OOP
in Java, Kotlin, and Swift.
Artificial Intelligence & Machine Learning: Python-based AI libraries like
TensorFlow and PyTorch use OOP.
3. What is inheritance? Explain with an example.
 Inheritance is a significant feature of OOP that supports creating new classes
from existing ones, allowing the new class to inherit attributes and methods
of the existing class.
Example:
#include <iostream>
using namespace std;
class Animal {
public:
void speak() {
cout << "This animal makes a sound." << endl;
}
};
class Dog : public Animal {
public:
void speak() {
cout << "Bark!" << endl;
}
};
int main() {
Animal a;
Dog d;
a.speak(); // Output: This animal makes a sound.
d.speak(); // Output: Bark!
return 0; }
4. Explain the terms polymorphism.
 Polymorphism allows objects to be treated as instances of their parents
class rather than their actual class. The means a single function or method
can work with di erent types of objects.
compile time: Multiple method with the same name but di erent
parameters.
Run-time: A child class can provide a specific implementation of a method
already defined in its parent class.
Importance:
Increases Flexibility: The same function can perform di erent behaviours in
di erent classes.
Reduces Code Complexity: A single interface can handle di erent data
types and behaviours.
Enhances Maintainability: Changes in method implementation do not a ect
the calling code.
5. Define the terms class and object.
 A class is a blueprint or template for creating objects. It defines attributes
(data members) and behaviours (member functions) of an object.
Example:
class Car {
public:
string brand; // Data member
int speed;
void display() { // Member function
cout << "Brand: " << brand << ", Speed: " << speed << " km/h" << endl;
} };

Software process Model

1. Explain the importance of system testing in the system development life


cycle (SDLC). [5 Marks]
 System testing is crucial in SDLC to ensure that the software meets the
specified requirements and functions correctly. Its importance includes:
a. Error Detection: Helps identify bugs and defects before deployment.
b. Performance Validation: Ensures the system performs e iciently under
expected conditions.
c. Security Assurance: Checks for vulnerabilities and enhances system
security.
d. User Satisfaction: Ensures that the final product meets user
expectations.
e. Compliance & Reliability: Helps in meeting industry standards and
making the software reliable.
2. Explain the requirement analysis phase of SDLC. [5 Marks]
 Requirement analysis is the first and most crucial phase of SDLC. It includes:
Gathering Requirements: Collecting user and business needs through
surveys, interviews, and discussions.
a. Analysing Requirements: Validating and prioritizing the collected
requirements.

b. Documenting Requirements: Creating Software Requirement


Specification (SRS) documents.

c. Feasibility Study: Checking if the project is technically and economically


feasible.

d. Approval & Sign-O : Getting confirmation from stakeholders before


proceeding to design.

3. Describe the waterfall software development model with pros and cons. [5
Marks]
 The Waterfall Model is a sequential approach in SDLC where each phase is
completed before moving to the next.
Pros:
a. Simple & Easy to Understand: Clearly defined stages and processes.

b. Structured Approach: Well-documented steps ensure clarity.

c. Good for Small Projects: Works well when requirements are well-
defined.

d. Easier to Manage: Each phase has a defined outcome.

Cons:

a. No Flexibility: Di icult to accommodate changes once the project starts.

b. Late Testing: Bugs are found in later stages, increasing costs.

c. Slow Development: Each phase must be completed before moving to


the next.
d. Not Suitable for Complex Projects: Cannot handle evolving
requirements well.

4. What are the major activities performed to design the software? Describe. [5
Marks]
 Software design involves several key activities:
a. Requirement Analysis: Understanding what needs to be developed.

b. System Architecture Design: Defining the system structure and


components.

c. Data Flow & Modeling: Creating diagrams like DFD and ER models.

d. User Interface Design: Designing user-friendly layouts and navigation.

e. Component Integration Planning: Ensuring smooth interaction between


di erent software modules.

5. What is feasibility study? Explain. [5 Marks


 A feasibility study evaluates whether a project is viable before development
begins. It includes:
a. Technical Feasibility: Determines if the required technology exists.

b. Economic Feasibility: Analyzes costs vs. benefits.

c. Legal Feasibility: Ensures compliance with regulations.

d. Operational Feasibility: Checks if the system will function well in


practice.

e. Schedule Feasibility: Determines if the project can be completed on


time.

6. Describe the desirable characteristics of a system analyst. [5 Marks]


 A System Analyst should have the following characteristics:
a. Analytical Skills: Ability to evaluate and solve complex problems.

b. Communication Skills: E ective interaction with stakeholders.

c. Technical Knowledge: Understanding of software, databases, and


networks.

d. Decision-Making Ability: Making informed choices for system design.

e. Project Management Skills: Ensuring smooth development and


implementation.

7. What are the roles of a system analyst in the SDLC phase? [5 Marks]
 The system analyst plays a crucial role in SDLC:
a. Requirement Gathering: Identifying user and system needs.

b. System Design: Creating models and diagrams for system architecture.

c. Communication Bridge: Linking business users and developers.

d. Problem Solving: Analyzing and resolving system-related issues.

e. Testing & Validation: Ensuring the system meets user requirements.

8. What are the importance of SDLC in the software development process? [5


Marks]
 SDLC is important because:
a. Structured Development: Provides a systematic approach.

b. Risk Management: Identifies and mitigates risks early.

c. Quality Assurance: Ensures high-quality software.

d. Cost & Time Management: Reduces unnecessary expenses and delays.

e. Scalability & Maintenance: Ensures software can be updated easily.

9. Define SDLC. Describe the feasibility analysis methods. [2+3 Marks]


 SDLC (Software Development Life Cycle) is a process used to develop
software systematically. It consists of phases like planning, design, coding,
testing, and deployment.
Feasibility Analysis Methods:
a. Technical Feasibility: Checks if technology is available.

b. Economic Feasibility: Evaluates cost-benefit ratio.

c. Operational Feasibility: Assesses system usability.

Recent Trends in Technology

1. What is cloud computing? Point out the advantage and disadvantage of


cloud computing. (1+4 Marks)
 Cloud Computing:
Cloud computing is a technology that allows users to access and store data,
applications, and services over the internet instead of a local computer or
server.
Advantages of Cloud Computing: (Any two for 2 marks)
a. Cost-E ective: No need to buy expensive hardware and software.

b. Scalability: Resources can be easily scaled up or down as needed.

c. Accessibility: Users can access data from anywhere with an internet


connection.
d. Automatic Updates: Software and security updates are managed by
cloud providers.

Disadvantages of Cloud Computing: (Any two for 2 marks)

a. Security Risks: Data stored on the cloud may be vulnerable to cyber


threats.

b. Internet Dependency: Requires a stable internet connection for access.

c. Limited Control: Users have less control over cloud infrastructure.

d. Downtime Issues: Cloud services may face outages a ecting


accessibility.

2. Explain the concept of cloud computing. (5 Marks)


 Cloud computing is an internet-based computing model that provides on-
demand access to shared computing resources like servers, storage,
databases, networking, and software. Instead of storing data and running
applications on personal devices, users can use cloud services through
providers such as Amazon Web Services (AWS), Google Cloud, and Microsoft
Azure.
Key Features:
a. On-Demand Self-Service: Users can provision resources as needed.

b. Broad Network Access: Accessible from anywhere via the internet.

c. Resource Pooling: Resources are shared among multiple users.

d. Scalability: Users can scale up or down as needed.

e. Pay-as-You-Go Model: Users pay only for what they use.

3. Write a short note on e-governance and e-commerce. (3+2 Marks)


 E-Governance (3 Marks):
E-Governance refers to the use of information and communication
technology (ICT) in government services to improve e iciency, transparency,
and citizen participation. It includes online portals for tax filing, digital IDs, e-
voting, and government service delivery.
 E-Commerce (2 Marks):
E-Commerce refers to the buying and selling of goods and services over the
internet. Examples include online shopping websites like Amazon, Flipkart,
and Alibaba. It provides convenience, wider product access, and digital
payment options.
4. Explain the popular five-application areas of AI. (5 Marks)
a. Healthcare: AI is used in disease diagnosis, robotic surgeries, and
personalized medicine.
b. Finance: AI helps in fraud detection, algorithmic trading, and risk
assessment.

c. Education: AI-powered tutors, virtual learning platforms, and


personalized learning experiences.

d. Transportation: AI is used in self-driving cars, tra ic management, and


predictive maintenance.

e. E-Commerce: AI is used for personalized recommendations, chatbots,


and demand forecasting.

5. How can you minimize computer crime? Explain. (5 Marks)


a. Use Strong Passwords: Secure accounts with complex passwords and
enable two-factor authentication.

b. Update Software Regularly: Keep operating systems and applications up


to date to prevent vulnerabilities.

c. Install Antivirus and Firewalls: Protect systems from malware, viruses,


and unauthorized access.

d. Avoid Phishing Scams: Do not click on unknown links or download


suspicious attachments.

e. Educate Users: Conduct cybersecurity awareness training to inform


users about online threats.

6. What is E-commerce? List out demerits of E-commerce. (1+4 Marks)


 E-Commerce (1 Mark):
E-Commerce is the process of buying and selling products or services
through the internet.
Demerits of E-Commerce (Any four for 4 Marks):
a. Security Issues: Cyber threats like hacking and data breaches.

b. Lack of Physical Interaction: Customers cannot physically inspect


products.

c. Dependence on Internet: Requires a stable internet connection.

d. Fraud and Scams: Risk of fraudulent transactions and fake products.

e. Delivery Delays: Shipping may take time, leading to customer


dissatisfaction.

7. What is AI? Describe the applications of AI. (2+3 Marks)


 Artificial Intelligence (AI) (2 Marks):
AI is the simulation of human intelligence in machines that can learn, reason,
and solve problems. It includes technologies like machine learning, deep
learning, and neural networks.
Applications of AI (Any three for 3 Marks):
a. Speech Recognition: AI-powered assistants like Siri, Google Assistant.

b. Autonomous Vehicles: AI is used in self-driving cars like Tesla.

c. Healthcare: AI helps in disease prediction, medical imaging, and robotic


surgeries.

d. Customer Service: AI chatbots handle customer queries.

e. Cybersecurity: AI detects and prevents cyber threats.

8. What are the importance of e-learning in the 21st century? Write the
importance of multimedia in e-learning. (3+2 Marks)
 Importance of E-Learning (3 Marks):
a. Accessibility: Education is available anytime, anywhere.

b. Cost-E ective: Reduces the cost of learning materials and travel.

c. Self-Paced Learning: Students can learn at their own pace.

 Importance of Multimedia in E-Learning (2 Marks):


a. Engages Learners: Videos, animations, and interactive content make
learning interesting.

b. Improves Understanding: Visuals help in better retention and


understanding of concepts.

9. What are the roles of AI in our real life? List out AI related systems in our
society. (1+4 Marks
 Role of AI in Real Life (1 Mark):
AI automates tasks, enhances decision-making, and improves e iciency in
various fields.
AI-Related Systems in Society (Any four for 4 Marks):
a. Smart Assistants: Alexa, Siri, Google Assistant.

b. Self-Driving Cars: AI in vehicles for autonomous navigation.

c. AI in Healthcare: AI-powered diagnosis and robotic surgeries.

d. AI in Finance: Fraud detection and algorithmic trading.

e. AI in Security: Facial recognition and cybersecurity solutions.

10. Define the terms e-governance and e-medicine. (2.5+2.5 Marks


 E-Governance (2.5 Marks): The use of ICT in government services for
e iciency, transparency, and citizen engagement. Examples: Digital
payments, online tax filing.
 E-Medicine (2.5 Marks): The use of digital technology in healthcare for
remote diagnosis, telemedicine, and online medical records.
11. Define the terms e-business and e-learning. (2.5+2.5 Marks)
 E-Business (2.5 Marks): Conducting business activities through the internet,
including online marketing, sales, and customer service.
 E-Learning (2.5 Marks): Learning through digital platforms such as online
courses, virtual classrooms, and e-books.
12. Explain Artificial Intelligence. (2+3 Marks)
 Artificial Intelligence (AI) (2 Marks): AI is the development of computer
systems that can perform tasks requiring human intelligence, such as
problem-solving and decision-making.
Features of AI (Any three for 3 Marks):
a. Machine Learning: AI systems learn from data.

b. Natural Language Processing: AI understands human language (e.g.,


Chatbots).

c. Computer Vision: AI processes images and videos (e.g., Facial


recognition).

d. Automation: AI performs tasks without human intervention.

13. What are the advantages and disadvantages of social media? (5 Marks)
 Advantages (Any two for 2.5 Marks):
a. Global Connectivity: Connects people worldwide.

b. Information Sharing: Quick access to news and knowledge.

c. Business Growth: Helps in digital marketing and brand promotion.

Disadvantages (Any two for 2.5 Marks):

a. Privacy Issues: Risk of data breaches and misuse.

b. Cyberbullying: Online harassment and fake identities.

c. Time-Wasting: Excessive use leads to decreased productivity.

You might also like