# Infosys Core CS Questions with Answers

8 previously-asked core cs questions from Infosys'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 a DDL command in SQL?

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

**Answer:** CREATE

**Explanation:** CREATE defines schema and is DDL. SELECT is DQL, while UPDATE and DELETE are DML.

### 2. Which data structure works on the First In First Out principle?

A. Stack
B. Queue
C. Tree
D. Graph

**Answer:** Queue

**Explanation:** A queue removes elements in the same order they were added, which is FIFO.

### 3. Which data structure is primarily used to manage function calls and recursion?

A. Queue
B. Stack
C. Array
D. Graph

**Answer:** Stack

**Explanation:** Function calls use a call stack (LIFO): the most recent call is completed first.

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

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

**Answer:** HAVING

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

### 5. Which statement best describes encapsulation in OOP?

A. Wrapping data and methods into a single unit and restricting direct access
B. Acquiring properties of a parent class
C. Having many forms of a method
D. Hiding implementation details only

**Answer:** Wrapping data and methods into a single unit and restricting direct access

**Explanation:** Encapsulation binds data and the methods that operate on it together and controls access through visibility modifiers.

### 6. What does a foreign key do in a relational database?

A. References the primary key of another table
B. Uniquely identifies rows in its own table only
C. Stores only numeric values
D. Prevents all duplicate rows

**Answer:** References the primary key of another table

**Explanation:** A foreign key links two tables by referencing the primary key of another table, enforcing referential integrity.

### 7. What is the main purpose of virtual memory in an operating system?

A. Allow programs larger than physical memory to run
B. Increase CPU clock speed
C. Replace the hard disk
D. Encrypt all data

**Answer:** Allow programs larger than physical memory to run

**Explanation:** Virtual memory uses disk space as an extension of RAM so processes can exceed available physical memory.

### 8. What is the worst case time complexity of quicksort?

A. O(n log n)
B. O(n^2)
C. O(log n)
D. O(n)

**Answer:** O(n^2)

**Explanation:** Quicksort degrades to O(n^2) in the worst case (for example an already sorted array with a poor pivot).

More Infosys preparation, including the full recruitment process: https://useastra.in/campus/infosys
