EmSAT Computer Science — Questions and Answers
Question 1: In Python, what is the output of the following code? x = [10, 20, 30, 40, 50] print(x[-2])
- 20
- 30
- 40 (Correct answer)
- 50
Correct answer: 40
Negative indices in Python count from the end of the list. Index -1 is the last element (50), so index -2 is the second-to-last element, which is 40.
Question 2: Which data structure follows the Last-In, First-Out (LIFO) principle?
- Queue
- Stack (Correct answer)
- Linked List
- Binary Tree
Correct answer: Stack
A stack operates on the LIFO principle — the last element pushed onto the stack is the first one to be popped off. A queue uses FIFO (First-In, First-Out) instead.
Question 3: A UAE university's IT department assigns the network address 192.168.10.0/24 to a campus lab. How many usable host IP addresses are available on this subnet?
- 256
- 255
- 254 (Correct answer)
- 128
Correct answer: 254
A /24 subnet contains 2^8 = 256 addresses. Two are reserved: one for the network address (192.168.10.0) and one for the broadcast address (192.168.10.255). That leaves 256 − 2 = 254 usable host addresses.
Question 4: In a relational database, which constraint ensures that a column's value uniquely identifies each row and cannot be NULL?
- FOREIGN KEY
- UNIQUE
- PRIMARY KEY (Correct answer)
- CHECK
Correct answer: PRIMARY KEY
A PRIMARY KEY combines two guarantees: uniqueness (no two rows can share the same value) and NOT NULL (the value must always be present). A UNIQUE constraint allows NULLs; a FOREIGN KEY references another table's key; CHECK validates a condition.
Question 5: Which layer of the OSI model is responsible for end-to-end data delivery, error detection, and flow control between two hosts?
- Network Layer (Layer 3)
- Data Link Layer (Layer 2)
- Transport Layer (Layer 4) (Correct answer)
- Session Layer (Layer 5)
Correct answer: Transport Layer (Layer 4)
The Transport Layer (Layer 4) handles end-to-end communication using protocols such as TCP (reliable, connection-oriented) and UDP (faster, connectionless). TCP provides error recovery and flow control. The Network Layer routes packets between networks; the Data Link Layer handles node-to-node delivery within the same network.
Question 6: A student receives an email appearing to be from the UAE Federal Authority for Identity, Citizenship, Customs & Ports Security, asking them to click a link and re-enter their Emirates ID number. This is an example of which type of cyberattack?
- Brute Force Attack
- Phishing (Correct answer)
- SQL Injection
- Denial of Service (DoS)
Correct answer: Phishing
Phishing is a social engineering attack in which an attacker impersonates a trusted organisation (here, a UAE government authority) to trick the victim into revealing sensitive personal information. Brute force attacks guess passwords; SQL injection targets databases; DoS floods a service to make it unavailable.
In Python, what is the output of the following code?
x = [10, 20, 30, 40, 50]
print(x[-2])