# TCS Core CS Questions with Answers

8 previously-asked core cs questions from TCS's hiring process, each with the correct answer and a worked explanation. Written against the company's actual test pattern.

_Source: Astra (https://useastra.in). Updated 2026-09-05._

### 1. Which of the following is NOT a necessary condition for a deadlock to occur?

A. Mutual exclusion
B. Hold and wait
C. Preemption
D. Circular wait

**Answer:** Preemption

**Explanation:** The four Coffman conditions are mutual exclusion, hold and wait, no preemption, and circular wait. Allowing preemption prevents deadlock.

### 2. Which normal form eliminates transitive dependency in a relational database?

A. 1NF
B. 2NF
C. 3NF
D. BCNF

**Answer:** 3NF

**Explanation:** Third Normal Form removes transitive dependencies, where a non-key attribute depends on another non-key attribute.

### 3. Which OOP feature lets a subclass give its own implementation of a method defined in its parent class?

A. Overloading
B. Overriding
C. Encapsulation
D. Abstraction

**Answer:** Overriding

**Explanation:** Method overriding is when a subclass redefines a method that already exists in its superclass with the same signature.

### 4. Which OSI layer is responsible for routing packets between networks?

A. Transport layer
B. Network layer
C. Data Link layer
D. Session layer

**Answer:** Network layer

**Explanation:** The Network layer (Layer 3) handles logical addressing and routing of packets across networks.

### 5. What is the time complexity of binary search on a sorted array of n elements?

A. O(n)
B. O(log n)
C. O(n log n)
D. O(1)

**Answer:** O(log n)

**Explanation:** Binary search halves the search space each step, giving logarithmic time complexity.

### 6. Which CPU scheduling algorithm can cause starvation of low priority processes?

A. FCFS
B. Round Robin
C. Priority scheduling
D. None of these

**Answer:** Priority scheduling

**Explanation:** In priority scheduling, low priority processes may wait indefinitely if higher priority processes keep arriving.

### 7. Which SQL command removes all rows from a table but keeps its structure and is a DDL operation?

A. DELETE
B. TRUNCATE
C. DROP
D. REMOVE

**Answer:** TRUNCATE

**Explanation:** TRUNCATE removes all rows quickly and is DDL, so it cannot be easily rolled back; DROP removes the table itself.

### 8. In a typical 64-bit system using GCC, what is the size of an int?

A. 2 bytes
B. 4 bytes
C. 8 bytes
D. 16 bytes

**Answer:** 4 bytes

**Explanation:** On common compilers such as GCC, int is 4 bytes; long is often 8 bytes on 64-bit systems.

More TCS preparation, including the full recruitment process: https://useastra.in/campus/tcs
