# Cognizant Core CS Questions with Answers

8 previously-asked core cs questions from Cognizant'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. What is the output? int a=5; a *= 2 + 3; print(a);

A. 25
B. 13
C. 10
D. 16

**Answer:** 25

**Explanation:** Assignment has lowest precedence, so 2+3 is evaluated first and a = 5 * 5 = 25.

### 2. What is the output? int x=4; x = x << 1; print(x);

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

**Answer:** 8

**Explanation:** Left shift by 1 multiplies by 2, so 4 becomes 8.

### 3. Which SQL clause is used to filter groups created by GROUP BY?

A. HAVING
B. WHERE
C. ORDER BY
D. DISTINCT

**Answer:** HAVING

**Explanation:** WHERE filters rows before grouping; HAVING filters aggregated groups after GROUP BY.

### 4. Which of the following is a DDL (Data Definition Language) command?

A. CREATE
B. UPDATE
C. DELETE
D. SELECT

**Answer:** CREATE

**Explanation:** CREATE defines schema objects; UPDATE, DELETE and SELECT are DML/DQL commands.

### 5. Which statement best describes a deadlock in an operating system?

A. Two or more processes each wait indefinitely for resources held by the others
B. A process is terminated by the OS to free memory
C. The CPU switches rapidly between processes
D. A process is moved from RAM to disk

**Answer:** Two or more processes each wait indefinitely for resources held by the others

**Explanation:** A deadlock is a circular wait where no involved process can proceed.

### 6. Which memory management technique divides memory into fixed-size blocks called pages?

A. Paging
B. Segmentation
C. Swapping
D. Fragmentation

**Answer:** Paging

**Explanation:** Paging maps fixed-size logical pages to physical frames, avoiding external fragmentation.

### 7. Which OOP feature lets the same function name behave differently based on its parameters?

A. Function overloading
B. Inheritance
C. Encapsulation
D. Abstraction

**Answer:** Function overloading

**Explanation:** Overloading resolves the correct function by number or type of arguments (compile-time polymorphism).

### 8. To which layer of the TCP/IP model does the HTTP protocol belong?

A. Application layer
B. Transport layer
C. Internet layer
D. Network Access layer

**Answer:** Application layer

**Explanation:** HTTP is an application-level protocol used by web clients and servers.

More Cognizant preparation, including the full recruitment process: https://useastra.in/campus/cognizant
