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.
1. 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, what does [3, 1, 2].sort() return?
[3, 2, 1]
[3, 1, 2]
An error
[1, 2, 3]
Answer: D) [1, 2, 3]
Explanation: Default sort converts to strings; single digits sort correctly. Scenario S13 · Areas: Web, Programming, Security
2. 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 admin' -- login is an example of:
SQL injection
Phishing
Cross-site scripting
DDoS
Answer: A) SQL injection
Explanation: The quote ends the string and -- comments out the password check. Scenario S05 · Areas: Security, Web, Databases
3. 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 document that formally lists what the system must do is the:
4. 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: The three apps share one backend. The best way for them to communicate with it is:
Email messages
A REST (or similar) API returning JSON
Shared Excel files
Each app connecting directly to the database with admin passwords
Answer: B) A REST (or similar) API returning JSON
Explanation: A common API keeps clients separate from the database. Scenario S06 · Areas: Software Engineering, Web, Cloud
5. 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: How should the PIN be stored?
As a salted slow hash (e.g. bcrypt), never in plain text
In plain text so support staff can read it
In the app's source code
Base64-encoded
Answer: A) As a salted slow hash (e.g. bcrypt), never in plain text
Explanation: Hashing with a salt protects PINs if the database leaks. Scenario S03 · Areas: Databases, Security, Software Engineering, Programming
6. 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: What is the network address of the second subnet?
7. 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: Which technology gives real-time two-way communication instead of repeated polling?
FTP
SMTP
WebSockets
Telnet
Answer: C) WebSockets
Explanation: A WebSocket keeps one connection open for both directions. Scenario S28 · Areas: Networks, Web, Programming
8. 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: A B-tree index lookup takes roughly:
9. 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: The 450 °C reading is an example of:
A categorical feature
An outlier / data error
A primary key
A missing value
Answer: B) An outlier / data error
Explanation: It should be removed or corrected during data cleaning. Scenario S20 · Areas: Data Analytics, Problem Solving, Programming
10. 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: Giving the application's cloud key only the permissions it needs would follow the principle of:
Least privilege
Open access
Defence by obscurity
Single sign-on
Answer: A) Least privilege
Explanation: It limits damage if the key leaks. Scenario S17 · Areas: Security, Software Engineering, Cloud
11. 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: Distributing incoming requests across several web servers is done by a:
Switch port
Load balancer
Compiler
DNS cache only
Answer: B) Load balancer
Explanation: It spreads traffic and removes single points of failure. Scenario S25 · Areas: Web, Cloud, Networks
12. 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: Which type of operating system is required?
A general desktop OS with no guarantees
A hard real-time operating system
A time-sharing OS for many users
A batch operating system
Answer: B) A hard real-time operating system
Explanation: Missing a deadline is unacceptable. Scenario S18 · Areas: Operating Systems, Software Engineering, Problem Solving
13. 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: What should be done FIRST?
Isolate infected computers from the network
Email the attachment to all staff for review
Delete the ransom note and continue work
Pay the ransom
Answer: A) Isolate infected computers from the network
14. 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: The daily temperatures for one week are 30, 32, 31, 35, 32. What is the median?
32
35
32.5
31
Answer: A) 32
Explanation: Sorted: 30, 31, 32, 32, 35 → middle value 32. Scenario S20 · Areas: Data Analytics, Problem Solving, Programming
15. Scenario – Server Crashes Under Heavy Jobs A video processing service runs on a Linux server with 8 GB RAM. When many users upload at once, the server becomes extremely slow: the disk light is always on and CPU usage drops while every process waits. A developer also notices two worker threads sometimes write to the same progress counter and the numbers come out wrong. Question: A good fix for the slowdown is to:
Start even more processes at once
Limit concurrent jobs (a job queue) or add memory/scale out
Turn off virtual memory and RAM
Defragment the CPU
Answer: B) Limit concurrent jobs (a job queue) or add memory/scale out
16. Scenario – Recommendation Engine for an Online Bookshop An online bookshop wants to show "Customers who bought this also bought…" on each book page. It has 5 years of purchase history. The data team also wants to group customers into segments for marketing, but they have no predefined segment labels. Question: Which SQL clause helps count how many times each pair of books was bought together?
17. 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: Which database feature can also block marks above 1100?
18. 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: Which chart best shows the temperature trend across the year?
Word cloud
Scatter plot of month names only
Line chart
Pie chart
Answer: C) Line chart
Explanation: Line charts show change over time. Scenario S20 · Areas: Data Analytics, Problem Solving, Programming
19. 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 recall for spam?
94%
80%
50%
99%
Answer: B) 80%
Explanation: 400 ÷ (400 + 100) = 0.8. Scenario S09 · Areas: AI/ML, Data Analytics, Problem Solving
20. 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: If backups are taken every 4 hours, the maximum possible data loss is about:
4 hours of work
0 minutes
24 hours of work
1 hour of work
Answer: A) 4 hours of work
Explanation: Anything since the last backup can be lost. Scenario S27 · Areas: Operating Systems, Cloud, Security
21. 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: Complaint tracking numbers should NOT be simple sequential numbers like 1001, 1002 because:
They are too long
Others could guess numbers and view complaints that are not theirs
Sequential numbers cannot be stored
Databases forbid them
Answer: B) Others could guess numbers and view complaints that are not theirs
Explanation: Guessable IDs lead to broken access control (IDOR) unless checked. Scenario S12 · Areas: Software Engineering, Web, Security
22. 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: The HTTP status code returned when a requested article does not exist is:
23. Scenario – Software House Project Delay A software house estimates a project at 12 weeks. Tasks: A (design, 2 weeks), B (backend, 5 weeks, after A), C (frontend, 4 weeks, after A), D (integration and testing, 3 weeks, after both B and C). Halfway through, the client asks for daily changes by phone, and testing finds many bugs in old features after each change. Question: What is the minimum project duration (critical path)?
12 weeks
14 weeks
10 weeks
9 weeks
Answer: C) 10 weeks
Explanation: A (2) + B (5) + D (3) = 10 weeks; C has 1 week of slack. Scenario S21 · Areas: Software Engineering, Problem Solving
24. 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: EBook and PrintedBook returning different loan days from the same method call is:
Overloading
Recursion
Encapsulation only
Polymorphism (method overriding)
Answer: D) Polymorphism (method overriding)
Explanation: The runtime type decides which method runs. Scenario S16 · Areas: Programming, DSA, Databases, Software Engineering
25. 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: To keep working during internet outages at the factory, they should:
Turn off the firewall
Store passwords on paper
Use two internet links from different ISPs (redundancy)
Use only one cheaper link
Answer: C) Use two internet links from different ISPs (redundancy)
Explanation: Redundant links remove a single point of failure. Scenario S15 · Areas: Cloud, Networks, Software Engineering