Monday, April 14, 2025

[Solution]2081 (2024) Computer Science Supplementary Examination SET A

 

NEB - GRADE XII

2081 (2024)

Computer Science

Supplementary Examination

Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.  

Time: 2 hrs.                                                SET A                                                                          Full Marks: 50

Group 'A'

Multiple choice questions                                                                     [9x1=9]  

1) Which SQL Query selects all records from a table named "Address" where the value of the column "Address" has its second last letter ending with an "a"?

A) SLELECT * FROM Address WHERE Address = 'a'

B) SELECT * FROM Address WHERE Address LIKE 'a_%'

C) SELECT * FROM Address WHERE Address LIKE '% a'

D) SELECT * FROM Address WHERE Address LIKE '%a_%'

 

2) What is used for data security in the database?

A) Data integrity

B) Data encryption

C) Data auditing

D) Data authentication

 

3) Which SQL command is used to define the field ID of the table student as PRIMARY KEY which has already been created with the schema (ID, Name, DOB, Address)?

A) ALTER TABLE Student ADD PRIMARY KEY (ID);

B) INSERT INTO Student ID PRIMARY KEY (ID);

C) ALTER TABLE Student ADD ID PRIMARY KEY;

D) INSERT INTO Student ADD ID PRIMARY KEY;

Note: A) ALTER TABLE Student ADD PRIMARY KEY (ID); Although this is close, it is not the correct syntax. It would be correct if the ID was not already created.

 

4) What type of transmission media is commonly used in LAN networks due to its cost-effectiveness and flexibility?

A) Twisted pair cable

B) Microwave

C) Digital subscriber line

D) Satellite

 

5) What is a scripting language that runs for the browser of the user's Computer?

A) Object-oriented programming

B) Server-side scripting language

C) Client-side scripting Language

D) Structure programming Language

 

6) Predict the correct output of the following PHP code.

 

                       <?php $x=30; $y = 30;

 

                       if ($x>$y) echo "CDC, Nepal.";

 

                       else echo "NEB, Nepal."; ?>

 

A) 30 is not greater than 30.                                                              

B) CDC, Nepal                          

C) NEB, Nepal.                                         

D) No output.

 

7) Analyse the expected output of the provided in JavaScript snippet.

 

                       <script> var P=120, Q=O; document.write (P/Q); </script>

 

A) Garbage value                          B) 0                           C) 120                               D) Infinity is pointed

 

8) Which feature of OOPs is used to derive the attributes and methods from base class?

A) Encapsulation                        B) Inheritance                         C) Polymorphism                                D) Data hiding

 

9) What is the Primary focus of the maintenance phase in the SDLC?

A) Conducting performance testing.

B) Enhancing system functionality based on user feedback.

C) Developing new features and modules for the system.

D) Documenting system requirements and specifications.

 

 

Group 'B'

Short answer questions                                                                          [5×5=25]

10. Evaluate the normalization process in relational databases. Provide examples to illustrate 2NF normalization form.

Ans:

Normalization is a database design process that involves breaking down or decomposing a complex relation (table) into simple multiple relations to minimize redundancy and dependency. The most commonly used normal forms are:

1)      First Normal Form (1NF)

2)      Second Normal Form (2NF)

3)      Third Normal Form (3NF)

4)      Boyce-Codd Normal Form (BCNF)

5)      Fourth Normal Form (4NF)

 

Example of 2NF Normalization:

1NF Table:

Student_ID

Student_Name

Course_ID

Course_Name

101

Alice

C01

Math

102

Bob

C02

Science

101

Alice

C02

Science

Primary Key: (Student_ID, Course_ID)

Issue: Partial Dependency: Course_Name depends only on Course_ID, not on the full composite key (Student_ID, Course_ID).

 

Dividing above 1NF table into seperate 2NF tables as follows:

Student_Courses Table:

Student_ID

Student_Name

Course_ID

101

Alice

C01

102

Bob

C02

101

Alice

C02

Courses Table:

Course_ID

Course_Name

C01

Math

C02

Science

Above two tables are in 2NF because:

a) No partial dependencies: Course_Name is now dependent only on Course_ID. So, No partial dependencies.

b) Less redundancy: Course names are stored separately, preventing duplicate data.

 

 

OR

Write the SQL DDL statement to create an employee table with the mentioned schema with the following attributes.

Field

Data type

Constraints

Employee ID

INT

PRIMARY KEY

Name

CHAR(30)

Address

CHAR(20)

Gender

CHAR(2)

Post

CHAR(15)

Ans:

The SQL DDL (Data Definition Language) statement to create an employee table with the specified attributes(fields), data type and constraints is as follows:

CREATE TABLE Employee

(

    Employee_ID INT PRIMARY KEY,

    Name CHAR(30),

    Address CHAR(20),

    Gender CHAR(2),

    Post CHAR(15)

);

 

Example Output:

Employee_ID

Name

Address

Gender

Post

1

Madhav Sapkota

Kathmandu

M

Manager

2

Sanjita Chaudhary

Surkhet

F

Teacher

Explanation:

Ø  CREATE TABLE Employee → Creates a table named Employee.

Ø  Employee_ID INT PRIMARY KEY → Defines Employee_ID as an integer and sets it as the Primary Key

Ø  Name CHAR(30) → Stores employee name with a max length of 30 characters.

Ø  Address CHAR(20) → Stores employee address with a max length of 20 characters.

Ø  Gender CHAR(2) → Stores gender (e.g., 'M', 'F') with a max length of 2 characters.

Ø  Post CHAR(15) → Stores job position (e.g., "Manager", "Teacher") with a max length of 15 characters.

 

11. Write a JavaScript code snippet, along with HTML, that displays the multiplication table of an entered number.

Ans:

<!DOCTYPE html>

<html>

<head>

    <title>Multiplication Table</title>

</head>

<body>

    <script>

        function multiplication()

        {

         var n;

         n = parseInt(prompt("Enter a number:"));

         document.write("Multiplication Table of " + n)

         for (var i = 1; i <= 10; i++)

         {

            document.write(n + " × " + i + " = " + (n * i) + "<br>");

         }

        }

        multiplication();

    </script>

</body>

</html>

 

Example Output:

Enter a number: 5

Multiplication Table of 5

5 × 1 = 5

5 × 2 = 10

5 × 3 = 15

5 × 4 = 20

5 × 5 = 25

5 × 6 = 30

5 × 7 = 35

5 × 8 = 40

5 × 9 = 45

5 × 10 = 50

 

OR

Develop a PHP code to add a record like (601, Raju, M, 12-06-2002, Kathmandu) in the table named info_stud having structure (reg_no integer, name character 25, gender character 1, dob character 10, address character 25) of the database named "School".

Ans:

A PHP code to insert the record (601, Raju, M, 12-06-2002, Kathmandu) into the table info_stud in the database "School" is as follows:

<?php

// Step 1: Database configuration

$servername = "localhost";

$username = "root";

$password = "";

$database = "School";

 

// Step 2: Database connection

$con = new mysqli($servername, $username, $password, $database);

 

// Step 3: Check connection

if ($con->connect_error)

{

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

} else {

    echo "Connected successfully!";

}

 

// Step 4: Prepare the SQL statement for insertion

$sql = "INSERT INTO info_stud (reg_no, name, gender, dob, address)

             VALUES (601, 'Raju', 'M', '12-06-2002', 'Kathmandu')";

 

// Step 5: Execute the query and check if data is inserted

if ($con->query($sql) === TRUE)

{

    echo "Record added successfully!";

} else {

    echo "Error: " . $sql . "<br>" . $con->error;

}

 

// Step 6: Close connection

$con->close();

?>

 

12. Define the term "Class". Explain the concept of encapsulation. How does it help in achieving data hiding in object-oriented programming?

Ans:

A class is a blueprint or template for creating objects. It defines a set of properties (attributes) and methods (functions) that the objects created from the class will have.

Encapsulation is a fundamental concept in Object-Oriented Programming (OOP) that involves wrapping(bundling) data (attributes) and methods (functions) into a single unit (class).

Encapsulation plays a crucial role in data hiding by restricting direct access to the internal details of an object. In Object-Oriented Programming (OOP), encapsulation allows a class to control how its data is accessed and modified by:

    1. Making Data Private: Class attributes (variables) can be declared as private so they cannot be accessed directly from outside the class.
    2. Providing Controlled Access: Instead of allowing direct access to data, encapsulation provides getter and setter methods.
    3. Hiding Internal Implementation Details: The internal workings of a class are hidden from external code, meaning users interact with the class through a controlled interface.

 

13. How does the System Development Life Cycle (SDLC) facilitate the efficient planning and execution of software development projects?

Ans:

The System Development Life Cycle (SDLC) facilitates efficient planning and execution of software development projects by providing a structured, step-by-step approach to software creation. It ensures that projects are completed on time, within budget, and with high quality. Here’s how SDLC helps:

1.       Structured Approach for Development:

It divides development into phases (planning, design, implementation, testing, deployment, and maintenance), reducing complexity and ensuring systematic progress.

2.       Better Planning and Resource Management:

It helps in better resource management, avoiding delays and cost overruns by clearly defining requirements, budget, and timelines

3.       Improved Quality and Risk Management:

It improves software quality through rigorous testing, early error detection, and risk mitigation.

4.       Clear Roles and Responsibilities:

       It assigns clear roles and responsibilities, enhancing team collaboration and communication.

5.       Flexibility with Different Models:

SDLC supports different methodologies like Waterfall, Agile, Spiral, allowing teams to choose the best approach based on project needs.

 

14. Define Robotics. Explain the application of Robotics in various fields such as industry and healthcare.

Ans:

Robotics is a branch of technology that involves the design, construction, operation, and use of robots to perform tasks autonomously or semi-autonomously. It integrates mechanical engineering, electronics, computer science, and artificial intelligence (AI) to develop machines that can mimic human actions or enhance efficiency in various domains.

Applications of Robotics in Various Fields such as industry and healthcare are as follows:

1. Industrial Applications:

Ø  Manufacturing: Robots automate assembly lines in industries like automotive and electronics, increasing precision and productivity.

Ø  Warehouse Automation: Companies like Amazon use robots for inventory management and order fulfilment.

Ø  Quality Control: Robots inspect products for defects, ensuring consistency in mass production.

2. Healthcare Applications:

Ø  Surgical Robots: Used in procedures like robotic-assisted surgeries (e.g., Da Vinci Surgical System).

Ø  Rehabilitation Robots: Assist patients in physical therapy and mobility improvement.

Ø  Medical Delivery Robots: Transport medicines and supplies in hospitals, reducing human contact in infection-prone areas.

 

 

Group 'C'

Long answer questions                                                                                     [2×8=16]

15. a) Why do network designers prefer to use switches in a LAN network? Explain briefly with any three suitable reasons.

Ans:

A switch is a device that connects multiple devices on a local network. It uses MAC addresses to forward data packets to the correct device on the network.

Network designers prefer to use switches in a LAN (Local Area Network) because they improve performance, efficiency, and security. Here are three key reasons:

1. Faster Data Transmission (Better Performance):

Ø  Switches use MAC addresses to forward data directly to the intended device instead of broadcasting to all devices (as hubs do).

Ø  This reduces network congestion and improves speed in high-traffic environments.

2. Enhanced Security:

Ø  Switches allow network segmentation using VLANs (Virtual LANs), preventing unauthorized access between departments.

Ø  Unlike hubs, which broadcast data to all devices, switches send data only to the intended recipient, reducing the risk of data interception.

3. Collision-Free Communication (Full-Duplex Mode):

Ø  Switches support full-duplex communication, meaning data can be sent and received simultaneously without collisions.

Ø  This increases network efficiency, especially in busy networks, compared to traditional hubs that operate in half-duplex mode.

 

b) Why do people prefer star topology as a LAN to set up in an organization like a bank? Give any three suitable reasons/purposes.

Ans:

Star topology is a network topology where all devices are connected to a central hub or switch, which manages communication.

People prefer star topology as a LAN to set up in an organization like a bank because it offers several advantages as follows:

1. Scalability and Centralized Management:

Ø  Easy to add or remove nodes without affecting the entire network.

Ø  Simplifies network monitoring and management with a central hub.

2. Reliability and Flexibility:

Ø  Node failures do not disrupt the entire network.

Ø  Supports various network media and configurations.

3. Cost-Effectiveness and Performance: 

Ø  Generally lower installation and maintenance costs.

Ø  Optimized for efficient data transfer.

These features make star topology a practical and efficient choice for many network designs in an organization like a bank.

 

16. a) Write a C program to check whether the given number is positive or negative using a user-defined function.

       Ans:

       #include<stdio.h>

#include<conio.h>

void check(int);

void main()

{

  int a;

  clrscr();

  printf("Enter a number:");

  scanf("%d", &a);

  check(a);

  getch();

}

void check(int x)

{

  if (x>0)

  printf("%d is a positive number",x);

  else if (x<0)

  printf("%d is a negative number",x);

  else

  printf("%d is a Zero",x);

}

 

Example Output:

Enter a number: 15

15 is a positive number

 

       b) Write a C program to find the product of two numbers using a pointer.

       Ans:

       #include <stdio.h>

       #include <conio.h>

void main()

{

    int a, b, *ptr1, *ptr2, p;

    clrscr();

    printf("Enter first number:");

    scanf("%d", &a);

    printf("Enter second number:");

    scanf("%d", &b);

    ptr1 = &a;

    ptr2 = &b;

    p = (*ptr1) * (*ptr2);

    printf("The product of two numbers is: %d", p);   

    getch();

}

 

Example Output:

Enter first number: 5

Enter second number: 10

The product of two numbers is: 50

OR

       Write a C program to store 10 student records with fields for roll numbers, names, and marks in computer       
       science. Process and display the roll numbers, names, and marks of students.

       science. Process and display the roll numbers, names, and marks of students.

Ans:

#include <stdio.h>

#include <conio.h>

struct student

{

    int rn, marks;

    char name[20];

};

void main()

{

    struct student s[10];

    int i;

    clrscr();

    for (i = 0; i < 10; i++)

    {

        printf("Enter Roll Number: ");

        scanf("%d", &s[i].rn);

        printf("Enter Name: ");

        scanf("%s", s[i].name);

        printf("Enter Marks in Computer Science: ");

        scanf("%d", &s[i].marks);

    }

    printf("\nROLL NO\tNAME\tMARKS");

    for (i = 0; i < 10; i++)

    {

        printf("\n%d\t%s\t%d", s[i].rn, s[i].name, s[i].marks);

    }

    getch();

}

 

Example Output:

Enter Roll Number: 101

Enter Name: Madhav

Enter Marks in Computer Science: 99

........

Enter Roll Number: 110

Enter Name: Sandesh

Enter Marks in Computer Science: 90

 

ROLL NO     NAME        MARKS

101              Madhav     99

........

110              Jack            90

 

 

THE END

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home