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.
51. Scenario – Hospital Queue Token System A hospital's token system serves patients in arrival order, but emergency patients must be seen before others. Average consultation is 6 minutes, and there are 3 doctors. At 9:00 AM, 45 regular patients are waiting. Question: To always serve emergency patients first, the best data structure is a:
Priority queue (heap)
Array of names only
Simple stack
Linked list sorted by name
Answer: A) Priority queue (heap)
Explanation: The highest-priority item is removed first. Scenario S24 · Areas: DSA, Operating Systems, Problem Solving
52. 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: Which technique helps reduce this problem?
Regularisation, more data and cross-validation
Training longer on the same data
Removing the test set
Adding random noise labels
Answer: A) Regularisation, more data and cross-validation
Explanation: These improve generalisation. Scenario S14 · Areas: AI/ML, Databases, Security, Problem Solving
53. Scenario – Online Admission Form A college's admission form collects name, CNIC, email, marks and a photo. Some applicants entered "abc" as their email and marks of 1200 out of 1100. Photos are uploaded to the web server's public folder with their original file names. One file was named "shell.php". Question: What is dangerous about the uploaded "shell.php" file?
It will make the site look different
It is just an image
It uses too much disk space only
If executed by the server, it can give the attacker remote control
Answer: D) If executed by the server, it can give the attacker remote control
Explanation: Uploads must be validated and stored where they cannot execute. Scenario S19 · Areas: Web, Databases, Security
54. Scenario – Exam Registration Website Gets Hacked A provincial testing body's registration site has a login form. Logs show the input admin' -- in the username field, after which an attacker logged in as admin. Later, a comment box on the site started showing a pop-up and redirecting visitors to a fake page. The site uses HTTP, not HTTPS. Question: Moving the site from HTTP to HTTPS mainly protects against:
SQL injection
Weak passwords
Server hardware failure
Eavesdropping and tampering in transit (MITM)
Answer: D) Eavesdropping and tampering in transit (MITM)
55. Scenario – Exam Registration Website Gets Hacked A provincial testing body's registration site has a login form. Logs show the input admin' -- in the username field, after which an attacker logged in as admin. Later, a comment box on the site started showing a pop-up and redirecting visitors to a fake page. The site uses HTTP, not HTTPS. Question: The comment box running a script in visitors' browsers is:
ARP spoofing
Stored cross-site scripting (XSS)
SQL injection
CSRF
Answer: B) Stored cross-site scripting (XSS)
Explanation: Fix with output encoding and Content Security Policy. Scenario S05 · Areas: Security, Web, Databases
56. 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: Why is accuracy a misleading metric here?
Accuracy only works for regression
Accuracy cannot be above 90%
The classes are imbalanced, so predicting "not spam" for all gives 95% accuracy
The data has too many features
Answer: C) The classes are imbalanced, so predicting "not spam" for all gives 95% accuracy
Explanation: With rare positives, precision, recall and F1 are more informative. Scenario S09 · Areas: AI/ML, Data Analytics, Problem Solving
57. Scenario – Weather Data Analysis An analyst has daily temperature data for Lahore for one year. Some days are missing, and one value is recorded as 450 °C due to a sensor fault. She wants to show the trend over the year and compare average temperatures by month. Question: To compare average temperature by month, she should:
Sort the data by temperature only
Delete all months except one
Group the data by month and compute the mean
Count the number of rows only
Answer: C) Group the data by month and compute the mean
Explanation: Aggregation (GROUP BY month) gives monthly averages. Scenario S20 · Areas: Data Analytics, Problem Solving, Programming
58. 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: How did students most likely cheat?
They hacked the database server physically
They read the answers or changed the score using the browser's developer tools
They used a faster internet connection
The quiz used too many images
Answer: B) They read the answers or changed the score using the browser's developer tools
Explanation: Anything in the browser can be viewed and modified by the user. Scenario S13 · Areas: Web, Programming, Security
59. 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 new SMS feature request should be handled through:
Secretly adding it without telling anyone
Ignoring it permanently
Restarting the project from zero
A change control process (impact, cost and schedule analysis)
Answer: D) A change control process (impact, cost and schedule analysis)
60. Scenario – News Website Goes Viral A news website's story goes viral. Visitors jump from 2,000 to 200,000 per hour. The site is built with server-side rendered pages that hit the database for every request, even though each article changes rarely. Many visitors are overseas. Question: To serve overseas visitors faster, the site should use:
61. 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: If they instead switch to a ready-made cloud ERP used through a browser, that is:
PaaS
IaaS
A private data centre
SaaS
Answer: D) SaaS
Explanation: Software as a Service – the provider manages everything. Scenario S15 · Areas: Cloud, Networks, Software Engineering
62. 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: Before result day, the team simulates 60,000 users to see when the system fails. This is:
Load (stress) testing
Usability testing
Regression testing only
Unit testing
Answer: A) Load (stress) testing
Explanation: Load and stress tests check performance under expected and extreme demand. Scenario S02 · Areas: Web, Networks, Databases, Software Engineering
63. Scenario – Branch Offices Network Design A company has a head office in Islamabad and branches in Karachi and Quetta. It has been given the private network 192.168.10.0/24 and must divide it into 4 equal subnets – one per site plus one for servers. Branch staff need to access the head office's accounting system securely over the internet. Question: How many usable host addresses does each of these subnets have?
64. 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: A developer writes: balance = balance - amount with amount taken directly from the request. Which check is MOST important to add?
Log the amount in red colour
Round amount to two decimals only
Validate that amount is positive and not more than the balance, on the server
Validate only in the mobile app's UI
Answer: C) Validate that amount is positive and not more than the balance, on the server
Explanation: A negative amount would add money; client-side checks can be bypassed. Scenario S03 · Areas: Databases, Security, Software Engineering, Programming
65. 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: Search queries like WHERE category = 'kurta' AND price < 3000 are slow on a 2-million-row table. The first fix to try is:
Convert the table to a spreadsheet
Add more columns
Delete old products
Create an index on (category, price)
Answer: D) Create an index on (category, price)
Explanation: A composite index avoids full table scans. Scenario S01 · Areas: Web, Cloud, Databases, Security
66. 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 its accuracy?
96%
80%
98%
99%
Answer: C) 98%
Explanation: (400 + 9,400) ÷ 10,000 = 0.98. Scenario S09 · Areas: AI/ML, Data Analytics, Problem Solving
67. Scenario – Hospital Queue Token System A hospital's token system serves patients in arrival order, but emergency patients must be seen before others. Average consultation is 6 minutes, and there are 3 doctors. At 9:00 AM, 45 regular patients are waiting. Question: Serving regular patients in arrival order uses a:
Binary tree
Hash table
Stack (LIFO)
Queue (FIFO)
Answer: D) Queue (FIFO)
Explanation: First in, first out. Scenario S24 · Areas: DSA, Operating Systems, Problem Solving
68. 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: Testing a single function like checkstock() in isolation is:
Unit testing
Acceptance testing
Load testing
System testing
Answer: A) Unit testing
Explanation: The smallest testable piece is checked alone. Scenario S26 · Areas: Programming, Software Engineering, Problem Solving
69. Scenario – Traffic Signal Controller A city installs smart traffic signals. Each controller must change lights within 50 milliseconds of a sensor signal; a delay could cause accidents. The software has four tasks: read sensors (every 10 ms), update lights, log data and send reports to the control room. Question: The sensor reading task should be given:
The highest priority
The lowest priority
Equal time with logging
No CPU time
Answer: A) The highest priority
Explanation: Safety-critical tasks get priority (often pre-emptive priority scheduling). Scenario S18 · Areas: Operating Systems, Software Engineering, Problem Solving
70. Scenario – Branch Offices Network Design A company has a head office in Islamabad and branches in Karachi and Quetta. It has been given the private network 192.168.10.0/24 and must divide it into 4 equal subnets – one per site plus one for servers. Branch staff need to access the head office's accounting system securely over the internet. Question: Dividing 192.168.10.0/24 into 4 equal subnets gives which prefix?
71. 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: Product images and CSS make up most of the bandwidth. What reduces load on the servers most cheaply?
Disable browser caching
Increase image resolution
Store images inside the database as BLOBs
Serve static files through a CDN with caching
Answer: D) Serve static files through a CDN with caching
Explanation: A CDN serves static content from edge locations near users. Scenario S01 · Areas: Web, Cloud, Databases, Security
72. 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: What should they release first to test the idea quickly?
A Minimum Viable Product (MVP) with core ordering and delivery features
A full AI recommendation engine
Every feature restaurants suggested
Only the marketing website
Answer: A) A Minimum Viable Product (MVP) with core ordering and delivery features
Explanation: An MVP gets real user feedback early. Scenario S06 · Areas: Software Engineering, Web, Cloud
73. Scenario – AI Admission Predictor Fairness A university trains a model to predict which applicants will succeed, using 10 years of past admission data. Testing shows the model rejects more applicants from rural districts with the same marks as urban applicants. The past data had very few rural students. Question: Predicting "success" or "failure" for each applicant is a:
Regression problem
Sorting problem
Classification problem
Clustering problem
Answer: C) Classification problem
Explanation: The output is a category. Scenario S29 · Areas: AI/ML, Ethics, Data Analytics
74. 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: Why did the backup fail to help?
It was always connected, so the ransomware encrypted it too
Backups never work
It used the wrong file system
USB drives cannot store files
Answer: A) It was always connected, so the ransomware encrypted it too
Explanation: Backups must be offline or off-site (3-2-1 rule). Scenario S08 · Areas: Security, Operating Systems, Cloud
75. 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: After fixing the loop, which indexes are printed?
1 only
0 and 2
1 and 3
3 only
Answer: C) 1 and 3
Explanation: stock[1] = 8 and stock[3] = 3 are below 10. Scenario S26 · Areas: Programming, Software Engineering, Problem Solving