Class 12 NEB Computer Science Q&A with Solutions

Class 12 · Computer Science · NEB

Complete Question & Answer Guide

A quick overview of important topics with revision-friendly points. Click any question to view guidance notes.

Note: This is a study overview, not an official answer key. Always cross-check with your textbook, teacher, and latest NEB pattern.

No matching question found. Try another keyword.
1

Database Management System

Def What is a database and DBMS? What are the advantages of DBMS over file system?

Database

A database is an organized collection of related data stored systematically so it can be easily accessed, managed, and updated.

DBMS

A Database Management System (DBMS) is software that allows users to create, store, manage, and retrieve data from a database. Examples: MySQL, Oracle, MS Access.

Advantages of DBMS over File System

  • No Data Redundancy: Data is stored once; no duplication.
  • Data Consistency: Changes in one place reflect everywhere.
  • Data Sharing: Multiple users can access data simultaneously.
  • Data Security: Access can be controlled through user permissions.
  • Data Integrity: Rules enforce accuracy and validity of data.
  • Easy Data Recovery: Backup and recovery mechanisms are built in.
  • Data Independence: Changes in structure don't affect programs.
Exam Tip: Always write at least 5 advantages. Start each with a bold key term.
Keys Define Primary Key, Candidate Key, and Alternate Key with examples.
Key Definition Example
Candidate Key Any attribute(s) that can uniquely identify a record StudentID, Email (both can identify a student)
Primary Key The candidate key selected by the designer to uniquely identify each row StudentID
Alternate Key Candidate keys NOT chosen as primary key Email (when StudentID is primary)
Primary Key cannot be NULL and must be unique. Every table has exactly one primary key.
Hot Differentiate DDL and DML with examples of commands.
DDL (Data Definition Language) DML (Data Manipulation Language)
Defines structure/schema of database Manipulates (manages) the data inside
Deals with tables, columns, structure Deals with rows and actual data
Changes are auto-committed Changes can be rolled back
CREATE, ALTER, DROP, TRUNCATE INSERT, UPDATE, DELETE, SELECT

Examples

DDL: CREATE TABLE Student (ID INT, Name VARCHAR(50));

DML: INSERT INTO Student VALUES (1, 'Ram');

Memory Trick: DDL = Design the table. DML = Deal with the data.
Hot What is Normalization? Explain 2NF and 3NF with examples.

Normalization

Normalization is the process of organizing a database to reduce redundancy and improve data integrity by dividing large tables into smaller ones.

2NF (Second Normal Form)

  • Must be in 1NF (no repeating groups).
  • Every non-key attribute must depend on the whole primary key, not just part of it.
  • Removes partial dependency.
Example: Table (StudentID, CourseID, StudentName, CourseName) → StudentName depends only on StudentID, not full key. Split into Student table and Course table.

3NF (Third Normal Form)

  • Must be in 2NF.
  • No non-key attribute should depend on another non-key attribute.
  • Removes transitive dependency.
Example: Table (StudentID, ZipCode, City) → City depends on ZipCode, not StudentID. Separate Zip-City into its own table.
Key terms to memorize: 2NF removes partial dependency. 3NF removes transitive dependency.
Model Explain the three types of database models: Hierarchical, Network, and Relational.
Model Structure Feature
Hierarchical Tree-like (parent → child) One parent, many children. Fast but rigid.
Network Graph (many-to-many links) More flexible; complex structure.
Relational Tables (rows and columns) Most popular. Uses SQL. Easy to understand.
Exam shortcut: Relational model is the most widely used — always highlight this point.
Comp Differentiate Centralized Database and Distributed Database.
Centralized Database Distributed Database
Stored at one single location Stored across multiple locations
Easy to manage and maintain Complex to manage
Single point of failure No single point of failure
Lower cost Higher cost
Slower access for remote users Faster local access
Example: School database on one server Example: Bank branches across the country
Security What is database security? Write any four methods to ensure it.

Database security refers to protecting the database from unauthorized access, misuse, and threats.

Methods of Database Security

  • Authentication: Verify user identity using username and password.
  • Authorization: Grant or restrict access rights to specific users.
  • Encryption: Convert data into unreadable format during storage/transfer.
  • Backup and Recovery: Regular data backup to restore in case of failure.
  • Audit Trail: Track all database activities to detect suspicious behavior.
2

Data Communication & Networking

Comm What is data communication? Explain its elements.

Data communication is the transfer of data/information between two or more devices through a communication medium.

Elements of Data Communication

  • Sender: The device that sends data (e.g., computer, phone).
  • Receiver: The device that receives data.
  • Message: The actual data/information being sent.
  • Transmission Medium: The path through which data travels (e.g., cable, air).
  • Protocol: A set of rules that govern data communication.
Mode Explain Simplex, Half Duplex, and Full Duplex modes of transmission.
Mode Direction Example
Simplex One direction only TV broadcast, keyboard → computer
Half Duplex Both directions but not at same time Walkie-talkie
Full Duplex Both directions simultaneously Mobile phone call
Hot What is a transmission medium? Explain guided and unguided media with advantages and disadvantages.

Transmission medium is the physical path through which data signals travel from sender to receiver.

A. Guided Media (Wired)

Data travels through physical cables.

  • Twisted Pair Cable: Two insulated copper wires twisted together. Cheap, used in telephone/LAN. Affected by noise.
  • Coaxial Cable: Central conductor with shielding. Used in cable TV. Better noise resistance.
  • Fiber Optic Cable: Transmits data as light. Very fast, long distance, immune to electromagnetic interference. Expensive.
Guided Advantages: Secure, reliable, high speed. Disadvantages: Limited by physical cable, costly installation.

B. Unguided Media (Wireless)

Data travels through the air.

  • Radio Waves: Used in FM radio, WiFi. Passes through walls.
  • Microwave: Line-of-sight transmission. Used in satellite communication.
  • Infrared: Short range. Used in TV remotes.
Unguided Advantages: No physical cables, flexible, easy setup. Disadvantages: Interference, security risks, limited range.
Hot Differentiate Star and Bus topology.
Star Topology Bus Topology
All devices connect to a central hub/switch All devices connect to a single main cable (bus)
If one device fails, others still work If backbone cable fails, whole network fails
Easy to troubleshoot Difficult to troubleshoot
More cabling required Less cabling required
Higher cost Lower cost
Used in modern LANs Used in small/old networks
Remember: Star is most commonly used today due to reliability.
Arch Differentiate Client-Server and Peer-to-Peer network architecture.
Client-Server Peer-to-Peer (P2P)
Central server manages resources All computers are equal, no central server
More secure and reliable Less secure
Requires dedicated server (costly) No dedicated server (cheaper)
Easy to manage Difficult to manage in large networks
Example: School's computer lab Example: File sharing between friends
OSI What is the OSI reference model? Name its seven layers and their functions.

The OSI (Open Systems Interconnection) model is a conceptual framework that describes how different network protocols interact in seven layers.

Layer Name Function
7 Application Interface for user applications (HTTP, FTP)
6 Presentation Data formatting, encryption, compression
5 Session Manages sessions/connections between computers
4 Transport End-to-end delivery (TCP/UDP)
3 Network Routing and IP addressing
2 Data Link Error detection, MAC addressing
1 Physical Transmits raw bits over medium
Mnemonic (top to bottom): "All People Seem To Need Data Processing"
LAN Differentiate LAN and WAN.
LAN (Local Area Network) WAN (Wide Area Network)
Covers small area (building/campus) Covers large geographic area (cities/countries)
High speed (up to Gbps) Slower speed
Low cost High cost
Low error rate Higher error rate
Example: College lab network Example: Internet
3

Web Technology II (JavaScript + PHP)

Theory Differentiate Client-Side Scripting and Server-Side Scripting.
Client-Side Scripting Server-Side Scripting
Runs on user's browser Runs on web server
Faster response (no server needed) Slower (server processes first)
Code is visible to user Code is hidden from user
Less secure More secure
Example: JavaScript, HTML, CSS Example: PHP, ASP, Python
Hot JavaScript program: Find the largest among three numbers.
<script> var a = parseInt(prompt("Enter first number:")); var b = parseInt(prompt("Enter second number:")); var c = parseInt(prompt("Enter third number:")); if (a > b && a > c) { document.write("Largest: " + a); } else if (b > c) { document.write("Largest: " + b); } else { document.write("Largest: " + c); } </script>
Also prepare: Smallest among three (just flip > to <) and Even/Odd check (use % 2 === 0).
Hot JavaScript program: Check if a number is Even or Odd using if-else.
<script> var n = parseInt(prompt("Enter a number:")); if (n % 2 == 0) { document.write(n + " is Even"); } else { document.write(n + " is Odd"); } </script>
PHP Write a PHP script to connect to a MySQL database. Explain mysqli_connect() and its parameters.

mysqli_connect() is a PHP function used to establish a connection to a MySQL database.

Syntax: mysqli_connect(host, username, password, database)

<?php $conn = mysqli_connect("localhost", "root", "", "mydb"); if (!$conn) { die("Connection Failed: " . mysqli_connect_error()); } else { echo "Connected successfully!"; } ?>

Parameters

  • host: Server name — usually "localhost"
  • username: Database user — usually "root"
  • password: Password — often empty ("") for local
  • database: Name of the database to connect to
PHP Write PHP variable naming rules and list PHP data types.

PHP Variable Naming Rules

  • Must start with a dollar sign: $name
  • Can contain letters, numbers, and underscore
  • Must start with a letter or underscore after $
  • Case-sensitive: $Name$name
  • Cannot use reserved keywords (e.g., $echo)

PHP Data Types

  • Integer — whole numbers: $a = 5;
  • Float — decimal numbers: $b = 3.14;
  • String — text: $c = "Hello";
  • Boolean — true/false: $d = true;
  • Array — collection: $e = array(1,2,3);
  • NULL — no value: $f = null;
4

Programming in C

Func What is a function in C? Explain its components. Differentiate library and user-defined functions.

A function is a block of code that performs a specific task and can be called multiple times in a program.

Components of a Function

  • Function Declaration (Prototype): Tells the compiler about the function name, return type, and parameters. E.g., int add(int a, int b);
  • Function Definition: Actual code of the function.
  • Function Call: Calling the function from main or another function. E.g., result = add(3, 5);
Library Function User-Defined Function
Pre-defined in C libraries Defined by the programmer
Ready to use with #include Must be written by user
Example: printf(), sqrt() Example: add(), findMax()
Hot Differentiate Call by Value and Call by Reference with examples.
Call by Value Call by Reference
Copy of value is passed Address (reference) is passed
Original value NOT changed Original value IS changed
Safer, no side effects Efficient for large data
Call by Value: Call by Reference: void add(int x) { void add(int *x) { x = x + 10; *x = *x + 10; } } add(a); // a unchanged add(&a); // a IS changed
Hot Write a C program using structure to store and display student records (name, roll, marks).
#include <stdio.h> struct Student { char name[50]; int roll; float marks; }; int main() { struct Student s; printf("Enter name: "); scanf("%s", s.name); printf("Enter roll number: "); scanf("%d", &s.roll); printf("Enter marks: "); scanf("%f", &s.marks); printf("\n--- Student Record ---\n"); printf("Name : %s\n", s.name); printf("Roll : %d\n", s.roll); printf("Marks : %.2f\n", s.marks); return 0; }
Key points to note: struct keyword, member access with dot (.), use of & in scanf for int/float.
File Explain binary file handling in C with an example program.

Binary file handling stores data in binary format (0s and 1s), not human-readable text. It is used to store structures, images, and complex data.

Key Functions

  • fopen(filename, "wb") — Open file for binary writing
  • fopen(filename, "rb") — Open file for binary reading
  • fwrite(&data, size, count, file) — Write binary data
  • fread(&data, size, count, file) — Read binary data
  • fclose(file) — Close the file
#include <stdio.h> struct Student { char name[50]; int roll; }; int main() { FILE *fp; struct Student s = {"Ram", 1}; fp = fopen("student.dat", "wb"); fwrite(&s, sizeof(s), 1, fp); fclose(fp); fp = fopen("student.dat", "rb"); fread(&s, sizeof(s), 1, fp); printf("Name: %s, Roll: %d\n", s.name, s.roll); fclose(fp); return 0; }
Ptr What is a pointer in C? Explain address operator (&) and indirection operator (*) with example.

A pointer is a variable that stores the memory address of another variable.

  • & (Address Operator): Returns the memory address of a variable. E.g., &a gives address of a.
  • * (Indirection/Dereference Operator): Accesses the value at the address stored in a pointer.
int a = 10; int *p = &a; // p stores address of a printf("%d", a); // Output: 10 printf("%d", *p); // Output: 10 (value at address) printf("%p", p); // Output: address of a
5

Object-Oriented Programming (OOP)

Hot Differentiate Object-Oriented Programming (OOP) and Procedure-Oriented Programming (POP).
OOP POP (Procedure-Oriented)
Focuses on objects and data Focuses on functions/procedures
Data is encapsulated (secure) Data is shared globally (less secure)
Supports inheritance, polymorphism No inheritance or polymorphism
Code is reusable Less code reusability
Top-down execution not needed Follows top-down approach
Examples: Java, C++, Python Examples: C, Pascal, COBOL
Hot Write a short note on Class and Object with an example.

Class

A class is a blueprint or template that defines the attributes (data) and behaviors (methods) of objects. It does not occupy memory by itself.

Object

An object is an instance (real occurrence) of a class. It occupies memory and has actual values.

Real-world analogy: Class = Blueprint of a house. Object = The actual house built from that blueprint.
class Student { // Class definition String name; int roll; void display() { System.out.println(name + " " + roll); } } Student s = new Student(); // Object creation s.name = "Ram"; s.roll = 1; s.display();
OOP What is Inheritance? Explain its types with examples.

Inheritance is an OOP feature where a child class acquires (inherits) properties and methods of a parent class. It promotes code reusability.

Types of Inheritance

  • Single: One child inherits from one parent. (A → B)
  • Multiple: One child inherits from multiple parents. (A, B → C)
  • Multilevel: A chain of inheritance. (A → B → C)
  • Hierarchical: Multiple children inherit from one parent. (A → B, A → C)
  • Hybrid: Combination of two or more types.
Example: Animal (parent) → Dog (child). Dog inherits eat() and sleep() from Animal, and adds its own bark().
OOP What is Polymorphism? Explain with an example.

Polymorphism means "many forms." In OOP, it allows the same method or operation to behave differently based on the object or context.

Types

  • Compile-time (Method Overloading): Same method name, different parameters. E.g., add(int, int) and add(float, float)
  • Runtime (Method Overriding): Child class redefines parent's method.
Real-world analogy: A person is a student at school, a child at home, a customer in a shop — same person, different roles.

Advantages of OOP

  • Code reusability through inheritance
  • Data security through encapsulation
  • Easier to debug and maintain
  • Models real-world problems naturally
6

Software Process Model

SDLC What is SDLC? Explain its phases.

SDLC (Software Development Life Cycle) is a process used to plan, design, develop, test, and deliver a software system.

Phases of SDLC

  • 1. Planning: Define project scope, goals, and feasibility.
  • 2. Requirement Analysis: Gather and document what the software must do.
  • 3. System Design: Design architecture, modules, and database.
  • 4. Implementation (Coding): Write the actual code.
  • 5. Testing: Find and fix errors/bugs.
  • 6. Deployment: Install and make software available to users.
  • 7. Maintenance: Update, fix, and improve after release.
Hot What is requirement gathering? Explain different methods of collecting requirements.

Requirement gathering is the process of collecting and documenting what a client or user needs from a software system.

Methods of Requirement Gathering

  • Interview: Direct conversation with clients/users to understand needs.
  • Questionnaire/Survey: Written set of questions distributed to many users.
  • Observation: Analyst observes users doing their actual work.
  • Document Review: Studying existing documents, reports, and manuals.
  • Prototyping: Build a rough model and gather feedback.
  • Brainstorming: Group discussion to generate ideas.
Exam tip: Write at least 4 methods with a brief explanation of each.
Model Explain Waterfall, Prototype, and Agile software development models.

Waterfall Model

Sequential, linear model. Each phase must be completed before moving to the next. Easy to manage but not flexible to changes.

Phases: Planning → Analysis → Design → Coding → Testing → Deployment

Prototype Model

A working prototype (demo) is built first and shown to the client. Feedback is used to refine the prototype repeatedly until the final system is ready. Good when requirements are unclear.

Agile Model

Development is done in small iterations called sprints (2–4 weeks). Continuous feedback and testing. Flexible and customer-focused. Best for fast-changing requirements.

Remember: Waterfall = rigid, Prototype = demo-based, Agile = flexible and iterative.
Quality What are the qualities of good software?
  • Correctness: Performs the intended task accurately.
  • Reliability: Works consistently without failure.
  • Efficiency: Uses minimum resources (memory, CPU).
  • Usability: Easy to learn and use by end users.
  • Maintainability: Easy to update and fix bugs.
  • Portability: Can run on different platforms/operating systems.
  • Scalability: Can handle growing users or data without issues.
  • Security: Protected against unauthorized access and threats.
Feasib What is feasibility study? Explain its types.

A feasibility study is an evaluation done before starting a project to determine whether it is possible and worthwhile to develop.

Types

  • Technical Feasibility: Does the organization have the technology, tools, and technical expertise to build it?
  • Economic Feasibility: Is the project affordable? Will benefits outweigh costs?
  • Operational Feasibility: Will users accept and use the system after it is built?
  • Legal Feasibility: Does the project comply with laws and regulations?
7

Recent Trends in ICT

Hot What is Artificial Intelligence (AI)? Explain its applications in education.

Artificial Intelligence

Artificial Intelligence (AI) is the simulation of human intelligence by machines. AI systems can learn, reason, solve problems, understand language, and make decisions.

Applications of AI in Education

  • Personalized Learning: AI adapts content to each student's pace and learning style.
  • Intelligent Tutoring Systems: AI tutors provide step-by-step guidance like a real teacher.
  • Automated Grading: AI grades assignments and multiple-choice tests instantly.
  • Chatbots: Answer student queries 24/7 without a teacher.
  • Learning Analytics: Tracks student progress and predicts those who may fall behind.
  • Content Creation: AI generates practice questions, summaries, and study materials.
Exam tip: Always define AI first, then list 4–5 applications clearly.
Hot What is Cloud Computing? Explain its service models: IaaS, PaaS, and SaaS.

Cloud Computing

Cloud computing is the delivery of computing services (servers, storage, databases, software) over the Internet ("the cloud") on a pay-as-you-use basis.

Service Models

Model Full Form What you get Example
IaaS Infrastructure as a Service Virtual hardware — servers, storage, networking AWS EC2, Google Compute
PaaS Platform as a Service Platform to develop and deploy apps Google App Engine, Heroku
SaaS Software as a Service Ready-to-use software over the internet Gmail, Google Docs, Zoom
Memory trick: IaaS = Infrastructure, PaaS = Platform, SaaS = Software. Pizza analogy: IaaS = ingredients, PaaS = kitchen, SaaS = delivered pizza!
IoT What is Internet of Things (IoT)? Write its applications.

Internet of Things (IoT) refers to a network of physical devices (things) embedded with sensors, software, and connectivity that allows them to collect and exchange data over the internet.

Applications of IoT

  • Smart Home: Smart lights, thermostats, security cameras controlled remotely.
  • Healthcare: Wearable devices monitor heart rate, blood pressure in real time.
  • Agriculture: Sensors monitor soil moisture, weather, and automate irrigation.
  • Transportation: GPS tracking, smart traffic management systems.
  • Manufacturing: Machines monitor themselves and report issues automatically.
Note Write short notes on: E-Commerce and Big Data.

E-Commerce

E-Commerce (Electronic Commerce) is the buying and selling of goods and services over the internet. It eliminates the need for physical stores.

Types: B2B (business to business), B2C (business to consumer), C2C (consumer to consumer).

Examples: Amazon, eSewa, Daraz.com.np

Big Data

Big Data refers to extremely large and complex datasets that cannot be processed by traditional tools. Characterized by 3Vs:

  • Volume: Huge amount of data
  • Velocity: High speed of data generation
  • Variety: Different types of data (text, video, sensor)

Used in: healthcare predictions, business analytics, social media analysis.

Note Write short notes on: Virtual Reality and Robotics.

Virtual Reality (VR)

Virtual Reality is a computer-generated simulation of a 3D environment that users can interact with using special headsets or devices, making them feel "immersed" in a virtual world.

Applications: Gaming, medical training, military simulation, virtual tourism.

Robotics

Robotics is the science and technology of designing, building, and operating robots — machines that can perform tasks automatically or semi-automatically.

Applications: Industrial assembly, surgery, space exploration, hazardous environments (bomb disposal).

Netra Koirala

Netra Koirala

Computer Science Educator

Passionate computer science educator and author. Provides free study notes, practical guides, and tutorials for Class 9, 10, 11, 12, and B.Sc CSIT students in Nepal. Years of teaching experience in computer science fundamentals.

Computer Science notes, tutorials, MCQs, and educational resources for Nepal students. Covering Class 9, SEE preparation, Class 11, Class 12, SLC, programming, DBMS, networking, HTML, JavaScript, PHP, OOP and more.

Featured Post

Grade 10 Computer Science: Specification Grid & Model Questions

Specification Grid & Model Questions of Computer Science | Grade 10 📚 Examination Resource Specification Grid & M...

Followers