Group 'A'
Rewrite the correct options of each question in your answer sheet.
1. Which of the following SQL statement is used to DELETE rows from a database
table?
A) DELETE
B) REMOVE
C) DROP
D) CLEAR
Ans: Option C: Drop
2. A field that is used to uniquely define a particular record in a table is
called:
A) Primary Key
B) Entity
C) Relationship
D) Constraints
Ans: Option A: Primary Key
3. What does "MAC" stands for in MAC Address?
A) Mandatory Access Control
B) Media Access Control
C) Micro Access Control
D) Media Access Certificate
Ans: Option B: Media Access Control
4. What is the correct syntax for referring to an external JavaScript
script?
A) <script src="myscript.js"></script>
B) <script href="myscript.js"></script>
C) <js href="myscript.js"></js>
D) <js src="myscript.js"></js>
Ans: Option A: <script src="myscript.js"></script>
5. Which of the following is the correct way of defining a variable in
PHP?
A) $variable name = value;
B) $variable_name = value;
C) $variable_name = value
D) $variable name as value;
Ans: Option B: $variable_name = value;
6. What is the output of C program?
void main(){ int b=25;
//b memory location=1234;
int *p; p=&b; printf("%d %d", &b, p);}
A) 25 25
B) 1234 1234
C) 25 1234
D) 1234 25
Ans: Option B: 1234 1234
7. Which feature of OOP is illustrated the code reusability?
A) Polymorphism
B) Abstraction
C) Encapsulation
D) Inheritance
Ans: Option D: Inheritance
8. Which of following is the discovering requirement from a user in the
requirement collection process?
A) Feasibility study
B) Requirement Elicitation
C) Requirement Specification
D) Requirement validation
Ans: Option B: Requirement Elicitation
9. What devices are detecting and responding to changes in an environment that
are embedded in smart phones and an integral part of the Internet of Things
(IoT)?
A) Wi-Fi
B) Barcode
C) RFID
D) Sensors
Ans: Option D: Sensors
Group 'B'
Short answer questions
10. Differentiate the centralized and distributed database system.
Ans:
Centralized and Distributed Database Systems are two different approaches for
managing data in a database. Here are the differences between the two:
Basis of Comparison |
Centralized |
Distributed |
Location |
It is managed by a single machine or system which is at a single
location |
It is spread and split up across various storage device locations |
Maintenance |
Easy to maintain |
Difficult to maintain |
Efficiency |
Less Efficient |
More Efficient |
Failure |
Entire data gets lost |
Still able to access other databases |
Response Speed |
Slow |
Fast |
Communication Cost |
High |
Low |
OR
What are the purposes of normalization? Give an example of 2NF.
Purpose of Normalization are:
a.
Normalization Process helps to produce cost-effective database
systems
b.
Normalization eliminates redundant (repetitive) data
c.
Normalization reduces the amount of storage needed to store the
data
d.
Normalization ensures that the data duplication is
minimized.
e.
Normalization avoids unnecessary data conflicts
f.
Normalization improves the database performance
g.
Normalization helps for faster searching of data
Example of 2NF:
In 2NF, a table must first meet the requirements of 1NF, and all non-key
attributes must depend on the entire primary key, not just part of it.
To illustrate, consider a hypothetical table of customers and their
orders:
Customer ID |
Order ID |
Product Name |
Quantity |
001 |
001 |
iPhone |
2 |
001 |
002 |
MacBook Pro |
1 |
002 |
003 |
iPad |
1 |
002 |
004 |
iMac |
1 |
In this table, the primary key is a combination of Customer ID and
Order ID. However, the Product Name attribute is dependent on
only the Order ID and not on the entire primary key. To normalize this
table to 2NF, we need to separate it into two tables:
Table 1: Orders
Order ID |
Customer ID |
001 |
001 |
002 |
001 |
003 |
002 |
004 |
002 |
Table 2: Order Details
Order ID |
Product Name |
Quantity |
001 |
iPhone |
2 |
002 |
MacBook Pro |
1 |
003 |
iPad |
1 |
004 |
iMac |
1 |
Now, the Product Name attribute is fully dependent on the entire
primary key of the Order Details table, which satisfies the
requirements of 2NF.
11. Write a program to find the factorial of any given number using
JavaScript.
Ans:
function factorial(num) {
if (num === 0) {
return 1;
} else {
return num *
factorial(num - 1);
}
}
const inputNum = prompt("Enter a number to find its factorial:");
const num = parseInt(inputNum);
if (isNaN(num)) {
console.log("Invalid input.
Please enter a valid number.");
} else {
const result =
factorial(num);
console.log(`The factorial of
${num} is: ${result}`);
}
OR
How do you fetch data from database in PHP and display it in form?
Describe.
Ans:
<html>
<title>Displaying queries in tables</title>
<body>
Displaying queries in tables <br>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "db_bca";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT * FROM student";
if($result = mysqli_query($conn, $sql)){
if(mysqli_num_rows($result) > 0){
echo "<table border=1>";
echo "<tr>";
echo "<th>RollNo</th>";
echo "<th>Name</th>";
echo "<th>Class</th>";
echo "<th>Marks</th>";
echo "<th>PhoneNo</th>";
echo "</tr>";
while($row = mysqli_fetch_array($result)){
echo "<tr>";
echo "<td>" . $row['RollNo'] . "</td>";
echo "<td>" . $row['Name'] . "</td>";
echo "<td>" . $row['Class'] . "</td>";
echo "<td>" . $row['Marks'] . "</td>";
echo "<td>" . $row['PhoneNo'] . "</td>";
echo "</tr>";
}
echo "</table>";
// Free result set
mysqli_free_result($result);
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($conn);
}
?>
</body>
</html>
12. Compare the OOPs and procedural programming language.
Ans:
Basic Comparison Between OOP and POP is:
Feature |
Object-Oriented Programming (OOP) |
Procedural Programming |
Basic Programming |
Objects and classes |
Functions and procedures |
Programming Paradigm |
Object-Oriented Programming Paradigm |
Imperative Programming Paradigm |
Data Abstraction |
Encapsulation, Inheritance, Polymorphism |
Structured programming |
Program Structure |
Program divided into Objects |
Program divided into Functions |
Data Handling |
Object State |
Global variables |
Data Access |
Methods or Functions |
Function parameters |
Code Reusability |
Highly reusable |
Reusability is difficult |
Memory Management |
Automatic garbage collection |
Manual memory management |
Error Handling |
Exception handling |
Error codes and returns |
13 What are the major activities performed to design the software?
Describe.
Ans:
The major activities performed to design software are:
-
Requirements analysis: Gathering and documenting requirements from
stakeholders.
-
Design: Creating a design solution that meets the requirements, including
architecture, data model, algorithms, and user interface.
-
Implementation: Writing and testing code based on the design.
-
Testing: Evaluating the software to ensure it meets the requirements and is
free of defects.
-
Deployment: Releasing the software to the end-users or customers.
-
Maintenance: Fixing bugs, adding new features, and updating the software to
meet changing requirements or environment.
14. Explain the popular five-application areas of AI.
Ans:
AI (Artificial Intelligence) has found its application in various fields. Here
are five popular application areas of AI:
-
Natural Language Processing (NLP): AI that helps computers understand
and use human language, used in chatbots, virtual assistants, and sentiment
analysis.
-
Computer Vision: AI that enables computers to interpret and
understand visual information, used in image and video recognition, facial
recognition, object detection, and self-driving cars.
-
Robotics: AI used in robots to improve their behavior and
decision-making abilities, used in manufacturing, healthcare, and other
industries.
-
Predictive Analytics: AI algorithms used to analyze data and predict
future outcomes, used in finance, healthcare, and marketing.
-
Gaming: AI used to create intelligent non-player characters (NPCs)
that respond to the player's actions and generate procedurally generated
content to make games more varied and exciting.
Group 'C'
Long answer questions
15. Compare the star and ring topology with pros and cons. Which of date
communication cable is more appropriate to design the local area network?
Describe.
Ans:
Star and ring topologies are two common network topologies used in Local Area
Networks (LANs). Here are some pros and cons of each topology:
Star Topology:
Pros |
Cons |
Easy to install and manage. |
Single point of failure in the central hub or switch, which can bring
down the entire network. |
Fault-tolerant as each device is connected to a central hub or switch,
so failure of one device does not affect the entire network. |
High cost as it requires additional equipment like hubs or switches. |
Scalable as new devices can be added to the network easily. |
Performance may be impacted by the capacity of the central hub or
switch. |
Ring Topology:
Pros |
Cons |
Efficient as data flows in a circular pattern with each device
transmitting and receiving data. |
Difficult to install and manage as it requires precise configuration
and maintenance. |
No collisions as only one device can transmit data at a time, which
reduces packet loss. |
Failure of one device can affect the entire network as data flows
through each device. |
Cost-effective as it requires less cabling than a star topology. |
Not easily scalable as adding new devices requires changes to the
entire network. |
Second Part:
The most commonly used cables for LAN are twisted pair cable, coaxial cable,
and fiber optic cable. Among them, the most used one is Fiber optic cable due
to its speed and reliability.
Fiber optic cable is the fastest and most expensive type of LAN cable. It uses
glass or plastic fibers to transmit data signals using light. Fiber optic
cable can transmit data over very long distances at very high speeds and is
often used in wide area networks (WANs). However, it is not commonly used in
small to medium-sized LANs due to its high cost.
16. What is structure? Write a program to input roll, name, and age of 5
students and display them properly using structure.
Ans:
Structure is one which is used to store related fields of different data
types. Simply structure is
one that can store heterogeneous data.
Program:
#include <stdio.h>
#include <string.h>
// Define a structure to store student details
struct Student {
int roll;
char name[50];
int age;
};
int main() {
// Declare an array of 5
Student structures
struct Student
students[5];
// Input details for each
student
for (int i = 0; i < 5;
i++) {
printf("Enter details for student %d:\n", i+1);
printf("Roll: ");
scanf("%d", &students[i].roll);
printf("Name: ");
scanf("%s", students[i].name);
printf("Age: ");
scanf("%d", &students[i].age);
printf("\n");
}
// Display the details of
all students
printf("Details of all
students:\n");
for (int i = 0; i < 5;
i++) {
printf("Roll: %d\n", students[i].roll);
printf("Name: %s\n", students[i].name);
printf("Age: %d\n\n", students[i].age);
}
return 0;
}
OR
Write a C program to enter ID, employee name, and post of the employee and
store them in a data file named "emp.txt". Display each record on the screen
in an appropriate format.
Ans:
#include <stdio.h>
struct Employee
{
int id;
char name[50];
char post[50];
};
int main() {
struct Employee
emp;
FILE *fp;
fp =
fopen("emp.txt", "a"); // open
file in append mode
// Input employee
details
printf("Enter
employee ID: ");
scanf("%d",
&emp.id);
printf("Enter
employee name: ");
scanf("%s",
emp.name);
printf("Enter
employee post: ");
scanf("%s",
emp.post);
// Write employee
details to file
fprintf(fp, "%d %s
%s\n", emp.id, emp.name, emp.post);
fclose(fp); // close file
// Display employee
details from file
fp =
fopen("emp.txt", "r"); // open
file in read mode
printf("\nEmployee
Details:\n");
while (fscanf(fp,
"%d %s %s", &emp.id, emp.name, emp.post) != EOF) {
printf("ID: %d\n", emp.id);
printf("Name: %s\n", emp.name);
printf("Post: %s\n\n", emp.post);
}
fclose(fp); // close file
return 0;
}