Computer Science Model Question 2079 (2023) — Solutions
NEB Grade XII · Subject Code: 4281
Time: 2 hoursFull marks: 50Subject code: 4281
These are independently written, exam-style study solutions based on the supplied question paper. They are not an official NEB marking scheme. In the examination, write answers in your own words and match the depth of each answer to the marks allotted.
Original question paper
The two supplied pages are included below so students can compare each solution with the original question.
Original question paper · Page 1Original question paper · Page 2
NEB Question Paper
Group A — Multiple-Choice Questions
9 × 1 = 9 marks
Write the correct option and answer. The question paper instructs candidates to rewrite the correct options in the answer sheet.
Q. No.
Correct option
Answer
1
A
First Normal Form (1NF)
2
D
Firewall
3
B
SELECT * FROM CUSTOMER WHERE LNAME LIKE '_A%';
4
B
192.168.1
5
C
PHP
6
C
var or let
7
D
$x . $y
8
D
It supports abstract data but not the class.
9
B
Economic feasibility
Brief explanations
First Normal Form (1NF): 1NF requires each table cell to contain a single, atomic value. Here, “atomicity” refers to atomic field values, not the ACID transaction property.
Firewall: Rollback, backup and recovery are database transaction or recovery mechanisms. The expected option in this MCQ is Firewall. A firewall is primarily a network security control that filters traffic; it is not a database transaction or recovery mechanism. In real systems, a firewall can still help protect database access at the network level.
Option B: In SQL LIKE, _ represents exactly one character and % represents zero or more characters. _A% therefore matches a last name whose second character is A.
Option B: A standard IPv4 address contains four decimal octets separated by dots. 192.168.1 has only three octets.
PHP: PHP is commonly used for server-side scripting. MySQL is a database management system, while jQuery is a JavaScript library.
var or let: Both are JavaScript variable declaration keywords. JavaScript also has const, although it is not listed in the options.
Dot operator: PHP uses the period (.) operator to concatenate strings, for example $fullName = $firstName . $lastName;.
Option D: Object-oriented programming supports classes as well as data abstraction. Therefore, the statement that it supports abstract data but not classes is incorrect. The wording of option B is imprecise: encapsulation restricts direct access to hidden data, but permitted methods can access or modify it.
Economic feasibility: Economic feasibility evaluates whether the expected benefits of a system justify its costs.
NEB Question Paper
Group B — Short-Answer Questions
5 × 5 = 25 marks
Question 10
[1 + 4 = 5]
Question: Which type of database system (centralized or distributed) is mostly preferred by financial institutions like a bank? Give any four suitable reasons.
Answer: A centralized database system is the expected answer in this textbook-style question. In a centralized database system, data is stored and managed at a central location, and authorized branches access it through a network.
Data consistency: All branches access the centrally maintained records, reducing conflicting or outdated customer balances.
Better centralized control: User permissions and access rules can be managed from one location.
Easier backup and recovery: Centralized backup and recovery procedures make it easier to protect important financial records.
Simpler administration and auditing: Updates, maintenance, monitoring and transaction records can be managed centrally.
Note for understanding: Real banking systems may combine central databases with distributed services, replicas and backup sites. The answer above follows the expected comparison in this model question.
OR
Alternative question: Nowadays most business organizations prefer applying the relational model for database design in comparison to other models. Justify the statement with your arguments. [5]
Answer: The relational database model stores data in related tables consisting of rows and columns. Business organizations commonly prefer it for the following reasons:
Simple structure: Tables make data easy to store, understand and manage.
Relationships between tables: Primary keys and foreign keys connect related records.
Reduced data redundancy: Proper database design and normalization reduce unnecessary duplication.
Data integrity: Constraints help maintain valid, accurate and consistent data.
Easy data access: SQL provides commands to search, insert, update, delete and combine records.
Question 11
[5]
Question: Develop a program in JavaScript to exchange/swap the values of any two variables.
Answer: A temporary variable can be used to exchange the values of two variables.
HTML + JavaScript
<!DOCTYPE html>
<html>
<head>
<title>Swap Two Variables</title>
</head>
<body>
<script>
let a = 10;
let b = 20;
let temp;
document.write("Before swapping: a = " + a + ", b = " + b + "<br>");
temp = a;
a = b;
b = temp;
document.write("After swapping: a = " + a + ", b = " + b);
</script>
</body>
</html>
Output:
Before swapping: a = 10, b = 20
After swapping: a = 20, b = 10
Explanation: The original value of a is first stored in temp. Then b is assigned to a, and the saved value in temp is assigned to b.
OR
Alternative question: How can you connect a database with PHP? Demonstrate with an example.
Answer: PHP can connect to a MySQL database using the MySQLi extension. The mysqli_connect() function establishes the connection.
The host, username, password and database name are specified.
mysqli_connect() attempts to connect PHP to the MySQL database.
mysqli_connect_error() displays the connection error if the connection fails.
A success message is displayed when the connection is established.
mysqli_close() closes the connection after use.
Question 12
[2 + 3 = 5]
Question: Describe the concept of Object-Oriented and Procedure-Oriented Programming in brief.
Object-Oriented Programming (OOP) [2]: OOP is a programming approach in which a program is organized around objects created from classes. An object combines data and the methods that operate on that data. It supports concepts such as encapsulation, inheritance, abstraction and polymorphism. Examples include Java and C++.
Procedure-Oriented Programming (POP) [3]: POP is a programming approach in which a program is divided into procedures or functions that perform specific tasks. It gives more emphasis to the sequence of instructions and functions. Data and functions are generally treated separately, and the program commonly follows a top-down design approach. C is a common example.
Question 13
[5]
Question: Write down any five qualities of good software.
Answer: Five important qualities of good software are:
Correctness: It performs the tasks according to the specified requirements.
Reliability: It works consistently and produces accurate results without frequent failure.
Usability: It is easy to learn, understand and operate.
Efficiency: It uses system resources such as memory, processing time and storage effectively.
Maintainability: It can be corrected, updated and improved without excessive difficulty.
Question 14
[5]
Question: Explain mobile computing with its advantages and disadvantages.
Answer: Mobile computing is the use of portable computing devices, such as smartphones, tablets and laptops, to access, process and exchange information through wired or wireless networks while the user is moving or away from a fixed location.
Advantages
Mobility: Users can access information while travelling or working away from the office.
Convenience: Communication, online services and information are available from different locations.
Higher productivity: Employees and students can perform tasks without always being at a fixed workstation.
Disadvantages
Connectivity problems: Network coverage or slow internet can interrupt services.
Security risks: Lost devices, insecure networks or weak passwords may expose private information.
Battery limitation: Portable devices depend on battery power and need regular charging.
NEB Question Paper
Group C — Long-Answer Questions
2 × 8 = 16 marks
Question 15
[2 + 6 = 8]
Question: Why do most business organizations prefer setting their network with the client-server architecture? Write its advantages and disadvantages.
Answer: Client-server architecture is a network model in which client computers request services or resources from a central computer called a server. The server manages resources and responds to client requests over a network.
Why organizations prefer it [2]
Business organizations prefer client-server architecture because it allows centralized management of data and resources, controlled access for users, easier backup and maintenance, and resource sharing among many clients.
Advantages
Centralized management: Data, applications and resources can be managed from the server.
Security: The server can enforce authentication, permissions and access controls.
Resource sharing: Multiple clients can share files, printers, databases and applications.
Disadvantages
High cost: Setting up and maintaining servers and networking equipment can be expensive.
Server dependency: If the main server fails, clients may lose access to important services.
Requires administration: Skilled personnel may be needed to manage, secure and maintain the server.
Question 16
[8]
Question: Develop a program in C using structure to ask the information of any 12 students with roll_number, name and marks scored in sub1, sub2 and sub3. Also, display them in proper format along with the calculation of total and percentage. Each subject carries 100 marks.
Answer: A structure is used to group each student's roll number, name and marks. An array of 12 structures stores the information of all students.
C
#include <stdio.h>
struct Student {
int roll_number;
char name[50];
int sub1, sub2, sub3;
};
int main(void) {
struct Student s[12];
int i, total;
float percentage;
/* Input information of 12 students */
for (i = 0; i < 12; i++) {
printf("\nEnter details of student %d\n", i + 1);
printf("Roll number: ");
scanf("%d", &s[i].roll_number);
printf("Name: ");
scanf(" %49[^\n]", s[i].name);
printf("Marks in subject 1, subject 2 and subject 3: ");
scanf("%d %d %d", &s[i].sub1, &s[i].sub2, &s[i].sub3);
}
/* Display student records with total and percentage */
printf("\n---------------- STUDENT RESULT ----------------\n");
printf("Roll No.\tName\t\tSub1\tSub2\tSub3\tTotal\tPercentage\n");
for (i = 0; i < 12; i++) {
total = s[i].sub1 + s[i].sub2 + s[i].sub3;
percentage = (total / 300.0) * 100;
printf("%d\t\t%-16s\t%d\t%d\t%d\t%d\t%.2f%%\n",
s[i].roll_number, s[i].name,
s[i].sub1, s[i].sub2, s[i].sub3,
total, percentage);
}
return 0;
}
Explanation:
struct Student groups the details of one student.
s[12] creates an array that can store 12 student records.
The first loop accepts each student's details.
total is calculated by adding the marks in all three subjects.
The maximum total is 300 because each subject carries 100 marks.
Percentage is calculated using (total / 300.0) * 100.
The second loop displays all records in tabular form.
OR
Alternative question: Demonstrate a program in C to create a data file named score.dat to store students' information with Reg_no, name, gender and address. The program should ask the user to continue or not. When finished, the program should also display all the records in the proper format.
Answer: The following program uses a structure and binary file handling. fwrite() stores each record in score.dat, and fread() reads the records back for display.
C
#include <stdio.h>
#include <stdlib.h>
struct Student {
int reg_no;
char name[50];
char gender[15];
char address[100];
};
int main(void) {
FILE *fp;
struct Student s;
char choice;
/* Open the file for writing in binary mode */
fp = fopen("score.dat", "wb");
if (fp == NULL) {
printf("Unable to create the file.\n");
return 1;
}
/* Input and store student records */
do {
printf("\nEnter registration number: ");
scanf("%d", &s.reg_no);
printf("Enter name: ");
scanf(" %49[^\n]", s.name);
printf("Enter gender: ");
scanf(" %14[^\n]", s.gender);
printf("Enter address: ");
scanf(" %99[^\n]", s.address);
if (fwrite(&s, sizeof(s), 1, fp) != 1) {
printf("Error writing to file.\n");
fclose(fp);
return 1;
}
printf("Do you want to add another record? (Y/N): ");
scanf(" %c", &choice);
} while (choice == 'Y' || choice == 'y');
fclose(fp);
/* Open the file for reading */
fp = fopen("score.dat", "rb");
if (fp == NULL) {
printf("Unable to open the file for reading.\n");
return 1;
}
printf("\n--------- STUDENT RECORDS ---------\n");
while (fread(&s, sizeof(s), 1, fp) == 1) {
printf("\nRegistration number: %d\n", s.reg_no);
printf("Name: %s\n", s.name);
printf("Gender: %s\n", s.gender);
printf("Address: %s\n", s.address);
}
fclose(fp);
return 0;
}
Explanation:
fopen("score.dat", "wb") creates the file for binary writing. It replaces an existing file with the same name.
The do-while loop accepts student records until the user enters N.
fwrite() writes each structure record into the file.
fclose() closes the file after writing.
fopen("score.dat", "rb") opens the file for binary reading.
fread() reads and displays each saved record until the end of the file.
The file is closed after reading.
Exam-writing reminders
For 1-mark MCQs, write the correct option letter and answer clearly, as instructed on the paper.
For 5-mark answers, begin with a definition and then give enough distinct, explained points to match the marks.
For 8-mark answers, use headings, explain each point and include a complete, correctly indented program when code is requested.
In programming questions, write the required header files, structure or variable declarations, main() function, input, processing, output and return 0;.
Keep question numbering the same as the question paper. For an OR question, answer one alternative in the examination unless instructed otherwise. This study resource includes both alternatives for revision.
Draw a diagram or table when it makes the explanation clearer. Label it properly.
These solutions are not an official marking scheme; final marking is determined by the examiner.