120 multiple-choice questions on NSCT: Integrated Scenarios from Computer Science, each with the correct answer and, where available, a teacher's explanation. Read through them to revise the chapter, then practise the same questions one by one to test yourself.
76. Scenario – Spam Filter for a Telecom A telecom company builds a model to flag spam SMS. In 10,000 messages, only 500 are spam. On the test set the model gives: TP = 400, FP = 100, FN = 100, TN = 9,400. Managers say "99% accuracy is great", but customers still complain about missed spam and some real messages being blocked. Question: What is the model's precision for spam?
99%
90%
98%
80%
Answer: D) 80%
Explanation: 400 ÷ (400 + 100) = 0.8. Scenario S09 · Areas: AI/ML, Data Analytics, Problem Solving
77. Scenario – Online Clothing Store on Sale Day KaprraHub, a Lahore-based online clothing store, runs a single web server and a MySQL database on one virtual machine. During last year's 11.11 sale, traffic rose 15 times, pages took 20 seconds to load and the site crashed for three hours. Customers also complained that product search is slow. The team has a small budget and wants to avoid this year's crash. Question: The checkout reduces stock and creates an order. Two customers buy the last item at the same moment and both succeed. Which concept solves this?
Using GET instead of POST
Denormalising the orders table
A larger font on the checkout page
A transaction with proper locking/isolation
Answer: D) A transaction with proper locking/isolation
Explanation: ACID transactions with row locking prevent overselling (a race condition). Scenario S01 · Areas: Web, Cloud, Databases, Security
78. Scenario – Cloud Migration for a Textile Mill A textile mill runs its ERP on an old server in the factory. Power cuts often shut it down. Management wants to move to the cloud but is worried about cost, control and internet outages. They want to keep running the same ERP software but stop managing hardware. Question: Keeping sensitive data on-site while using the public cloud for other workloads is a:
Peer-to-peer network
Community cloud only
Hybrid cloud
Public cloud only
Answer: C) Hybrid cloud
Explanation: Hybrid combines private and public cloud. Scenario S15 · Areas: Cloud, Networks, Software Engineering
79. Scenario – Inventory System Bug Hunt A shop's inventory program in Python should print a warning when stock is below 10. A developer wrote: python stock = [12, 8, 15, 3] for i in range(1, len(stock)): if stock[i] < 10: print("Low:", i) The owner says item 0 is never checked, and wants the code to be easy to test. Question: Why is item 0 never checked?
Lists in Python start at 1
The comparison should be 10
range(1, len(stock)) starts at index 1
print cannot show numbers
Answer: C) range(1, len(stock)) starts at index 1
Explanation: range(len(stock)) or range(0, …) is needed. Scenario S26 · Areas: Programming, Software Engineering, Problem Solving
80. Scenario – Ride-Hailing Database at Scale A ride-hailing company stores every trip (TripID, RiderID, DriverID, Fare, City, Timestamp). The table has 300 million rows. The app's "My trips" page searches by RiderID and is slow. Analysts also run huge monthly reports on the same database, which slows down the live app. Question: What will speed up the "My trips" page most directly?
Storing trips in a linked list in memory
Removing the primary key
A SELECT without a WHERE clause
An index on RiderID
Answer: D) An index on RiderID
Explanation: A B-tree index turns a full scan into a fast lookup. Scenario S11 · Areas: Databases, Cloud, DSA
81. Scenario – Mobile Wallet Money Transfer PaySaathi, a fintech startup, lets users send money from their wallet to another user. The transfer subtracts money from the sender's balance and adds it to the receiver's. During testing, a power failure happened after the subtraction but before the addition – the money disappeared. The app also stores the user's 4-digit PIN in the database. Question: Which database property guarantees that a transfer happens completely or not at all?
Atomicity
Durability only
Normalisation
Isolation only
Answer: A) Atomicity
Explanation: The A in ACID: all-or-nothing. Scenario S03 · Areas: Databases, Security, Software Engineering, Programming
82. Scenario – Login Page Under Attack A job portal's logs show 50,000 failed login attempts in an hour from many IP addresses, using common passwords like "123456" and "pakistan123" against many usernames. Some accounts were compromised because their owners used the same password on a leaked forum. Question: A password policy requires 8 characters from 26 lowercase letters only. How many possible passwords is that?
26^8
2^8
8^26
26 × 8
Answer: A) 26^8
Explanation: Each of 8 positions has 26 choices (about 209 billion). Scenario S30 · Areas: Security, Web, Problem Solving
83. Scenario – Data Centre Power and Storage A company's file server stores 20 TB of design files on one hard disk. Last month the disk failed and two days of work were lost. The company wants to survive one disk failure without downtime and to recover from accidental deletion. Question: Which RAID level survives one disk failure using striping with parity?
RAID 0
RAID 1 only with one disk
RAID 5
No RAID
Answer: C) RAID 5
Explanation: RAID 5 rebuilds a failed disk from parity. Scenario S27 · Areas: Operating Systems, Cloud, Security
84. Scenario – Chat App Message Delivery A team builds a live chat app. At first the browser asks the server every 2 seconds "Any new messages?", which creates heavy load. Messages must arrive in order and without loss. Voice calls are planned later, where small losses are acceptable but delay is not. Question: For live voice calls, the usual transport protocol is:
SMTP
UDP
TCP only
HTTP/1.0 polling
Answer: B) UDP
Explanation: UDP has lower delay; small losses are tolerable. Scenario S28 · Areas: Networks, Web, Programming
85. Scenario – Bank Fraud Detection Pipeline A bank collects card transactions (amount, time, merchant, city) to train a fraud model. The model scored 99.5% on training data but only 70% on new data. Amount ranges from Rs 10 to Rs 5,000,000 while other features are between 0 and 1. Customer card numbers are included in the training files shared with an outside vendor. Question: A model that is excellent on training data but poor on new data is:
Normalised
Underfitting
Perfectly fitted
Overfitting
Answer: D) Overfitting
Explanation: It memorised noise instead of learning patterns. Scenario S14 · Areas: AI/ML, Databases, Security, Problem Solving
86. Scenario – Hospital Records System A hospital in Peshawar stores patients, doctors and appointments in one spreadsheet-like table: (PatientID, PatientName, Phone, DoctorID, DoctorName, DoctorSpecialty, AppointmentDate). When a doctor changes specialty, staff must update hundreds of rows, and some rows are missed. Patient data is sensitive and the hospital wants to move to a proper system. Question: Receptionists should see appointment times but not diagnoses. The right control is:
A faster CPU
Removing passwords
Role-based access control (RBAC)
A bigger monitor
Answer: C) Role-based access control (RBAC)
Explanation: Permissions are granted by role. Scenario S04 · Areas: Databases, Security, Software Engineering
87. Scenario – Library Management System Design Students are building a library system in Java. A Book has title, ISBN and author; EBook and PrintedBook both extend Book and override getLoanDays(). The librarian wants to search a book by ISBN instantly among 200,000 books and to see books ordered by title. Question: To list books in title order efficiently while still allowing inserts, a good choice is a:
Hash table
Stack
Queue
Balanced binary search tree (e.g. TreeMap)
Answer: D) Balanced binary search tree (e.g. TreeMap)
Explanation: In-order traversal of a BST gives sorted order. Scenario S16 · Areas: Programming, DSA, Databases, Software Engineering
88. Scenario – Ride-Hailing Database at Scale A ride-hailing company stores every trip (TripID, RiderID, DriverID, Fare, City, Timestamp). The table has 300 million rows. The app's "My trips" page searches by RiderID and is slow. Analysts also run huge monthly reports on the same database, which slows down the live app. Question: To stop analyst reports from slowing the live app, the best option is:
Disable indexes
Delete old trips every day
Run reports more often
Run reports on a read replica or a separate data warehouse
Answer: D) Run reports on a read replica or a separate data warehouse
89. Scenario – Bank Fraud Detection Pipeline A bank collects card transactions (amount, time, merchant, city) to train a fraud model. The model scored 99.5% on training data but only 70% on new data. Amount ranges from Rs 10 to Rs 5,000,000 while other features are between 0 and 1. Customer card numbers are included in the training files shared with an outside vendor. Question: The very large range of "amount" compared with other features should be handled by:
Deleting the amount column always
Feature scaling (normalisation or standardisation)
Converting it to text
Sorting the rows
Answer: B) Feature scaling (normalisation or standardisation)
Explanation: Scaling stops one feature dominating distance-based or gradient methods. Scenario S14 · Areas: AI/ML, Databases, Security, Problem Solving
90. Scenario – Ransomware at a Small Business An accounting firm in Faisalabad found all its files renamed with ".locked" and a ransom note demanding Bitcoin. An employee had opened an email attachment called "Invoice.pdf.exe" the day before. Backups were stored on a USB drive that was always plugged into the same server, and it was encrypted too. Question: Which control would most reduce this risk in future?
Sharing one admin account
Disabling updates
Staff phishing awareness training plus offline/cloud versioned backups
Removing all antivirus
Answer: C) Staff phishing awareness training plus offline/cloud versioned backups
Explanation: People and backups are the main defences against ransomware. Scenario S08 · Areas: Security, Operating Systems, Cloud
91. Scenario – Cloud Migration for a Textile Mill A textile mill runs its ERP on an old server in the factory. Power cuts often shut it down. Management wants to move to the cloud but is worried about cost, control and internet outages. They want to keep running the same ERP software but stop managing hardware. Question: Renting virtual machines in the cloud to run the same ERP is an example of:
On-premises hosting
FaaS only
IaaS
SaaS
Answer: C) IaaS
Explanation: Infrastructure as a Service gives VMs; the customer manages the OS and app. Scenario S15 · Areas: Cloud, Networks, Software Engineering
92. Scenario – Campus Wi-Fi Problems A university hostel's Wi-Fi is slow in the evening. The IT team finds that one laptop is sending thousands of packets per second to many IP addresses, and some students are using a hotspot named "Hostel-WiFi-Free" that was set up by an unknown person. The access points still use WEP. Question: The laptop sending packets to many IP addresses is most likely:
Infected with a worm or part of a botnet
Running a text editor
Charging its battery
Updating its fonts
Answer: A) Infected with a worm or part of a botnet
Explanation: Worms scan and spread across networks. Scenario S22 · Areas: Networks, Security, Operating Systems
93. Scenario – E-Government Complaint Portal A provincial government asks a software house to build a citizens' complaint portal. The contract fixes the requirements, budget and deadline. Citizens must be able to track complaints by a number. The client later asks for an "urgent" SMS feature after the design phase is complete. Question: "The portal must load in under 3 seconds for 5,000 users" is a:
94. Scenario – Inventory System Bug Hunt A shop's inventory program in Python should print a warning when stock is below 10. A developer wrote: python stock = [12, 8, 15, 3] for i in range(1, len(stock)): if stock[i] < 10: print("Low:", i) The owner says item 0 is never checked, and wants the code to be easy to test. Question: This kind of off-by-one error is most quickly found by:
Rewriting the program in another language
Tracing the loop with a small example (dry run) or a debugger
Buying a faster computer
Adding more comments only
Answer: B) Tracing the loop with a small example (dry run) or a debugger
Explanation: A dry run shows which indexes are visited. Scenario S26 · Areas: Programming, Software Engineering, Problem Solving
95. Scenario – Online Quiz App With JavaScript A teacher builds an online quiz in plain JavaScript. The correct answers are stored in a JavaScript array in the page, and the score is calculated in the browser and sent to the server as score=8. Some students got full marks without studying. Question: In JavaScript, "5" + 3 gives:
NaN
"8"
8
"53"
Answer: D) "53"
Explanation: With a string, + concatenates. Scenario S13 · Areas: Web, Programming, Security
96. Scenario – Food Delivery App Planning Three graduates want to launch a food delivery app in Multan within 3 months. They are not sure which features customers want; restaurant owners keep suggesting new ideas. They plan a customer app, a rider app and a restaurant dashboard, and expect to change things often. Question: To avoid buying servers up front and pay only for what they use, they should choose:
A mainframe
A rented office server room
A cloud platform (IaaS/PaaS) with pay-as-you-go pricing
Personal laptops as servers
Answer: C) A cloud platform (IaaS/PaaS) with pay-as-you-go pricing
Explanation: Cloud converts capital cost into operating cost. Scenario S06 · Areas: Software Engineering, Web, Cloud
97. Scenario – Startup's GitHub Leak A junior developer pushed code to a public GitHub repository. The code contained the cloud database password and an AWS access key in a config file. Within an hour, unknown servers were started on the company's cloud account, costing thousands of dollars. Question: What should the team do FIRST?
Revoke/rotate the exposed keys and passwords immediately
Wait for the monthly bill
Change the repository name
Delete the commit and hope no one saw it
Answer: A) Revoke/rotate the exposed keys and passwords immediately
Explanation: Leaked credentials must be invalidated at once. Scenario S17 · Areas: Security, Software Engineering, Cloud
98. Scenario – Ride-Hailing Database at Scale A ride-hailing company stores every trip (TripID, RiderID, DriverID, Fare, City, Timestamp). The table has 300 million rows. The app's "My trips" page searches by RiderID and is slow. Analysts also run huge monthly reports on the same database, which slows down the live app. Question: Splitting the trips table across several servers by city is called:
Hashing passwords
Normalisation
Encryption
Sharding (horizontal partitioning)
Answer: D) Sharding (horizontal partitioning)
Explanation: Each shard holds a subset of rows. Scenario S11 · Areas: Databases, Cloud, DSA
99. Scenario – Library Management System Design Students are building a library system in Java. A Book has title, ISBN and author; EBook and PrintedBook both extend Book and override getLoanDays(). The librarian wants to search a book by ISBN instantly among 200,000 books and to see books ordered by title. Question: Which data structure gives average O(1) lookup by ISBN?
Unsorted array
Linked list
Stack
Hash table (HashMap)
Answer: D) Hash table (HashMap)
Explanation: Hashing maps a key directly to a bucket. Scenario S16 · Areas: Programming, DSA, Databases, Software Engineering
100. Scenario – University Result Portal A public university publishes semester results on a portal. On result day 60,000 students log in within one hour. Last time, the database CPU hit 100% because every page load re-ran a heavy query joining students, courses and marks. Results never change after they are published. Students in remote areas have slow mobile internet. Question: To make pages load faster on slow mobile connections, the developers should:
Use only very large images
Load all fonts and libraries on every page
Add autoplay videos
Minify and compress (gzip/Brotli) assets and keep pages light
Answer: D) Minify and compress (gzip/Brotli) assets and keep pages light
Explanation: Smaller payloads mean faster loads on slow networks. Scenario S02 · Areas: Web, Networks, Databases, Software Engineering