Sproutern LogoSproutern

Cognizant Interview Questions 2025

Comprehensive collection of technical, HR, and coding questions asked in Cognizant interviews for freshers.

Technical Interview Questions

Q1. What is Object-Oriented Programming? Explain its four pillars.

OOP is a programming paradigm based on objects containing data and code. The four pillars are: 1) Encapsulation - bundling data and methods together, 2) Abstraction - hiding complex implementation details, 3) Inheritance - deriving new classes from existing ones, 4) Polymorphism - one interface, multiple implementations.

Q2. Explain the difference between Stack and Heap memory.

Stack memory is used for static allocation and stores local variables/function calls. It follows LIFO and is automatically managed. Heap memory is used for dynamic allocation, stores objects, and requires manual memory management (in C/C++) or garbage collection (Java). Stack is faster but limited in size.

Q3. What is the difference between an abstract class and an interface?

Abstract class can have both abstract and concrete methods, supports constructors, and allows single inheritance. Interface traditionally had only abstract methods (Java 8+ allows default methods), no constructors, and supports multiple inheritance. Use abstract class for 'is-a' relationship and interface for 'can-do' capabilities.

Q4. Explain ACID properties in databases.

ACID ensures reliable database transactions. Atomicity - transaction is all or nothing. Consistency - database remains in valid state. Isolation - concurrent transactions don't interfere. Durability - committed changes persist even after system failure.

Q5. What are joins in SQL? Explain different types.

Joins combine rows from two or more tables based on related columns. Types: INNER JOIN (matching rows only), LEFT JOIN (all from left + matching), RIGHT JOIN (all from right + matching), FULL JOIN (all from both), CROSS JOIN (cartesian product), SELF JOIN (table joined with itself).

Q6. What is normalization? Explain different normal forms.

Normalization organizes data to reduce redundancy. 1NF: atomic values, no repeating groups. 2NF: 1NF + no partial dependencies. 3NF: 2NF + no transitive dependencies. BCNF: 3NF + every determinant is a candidate key. Higher forms reduce redundancy but may impact query performance.

Q7. Explain the concept of multithreading.

Multithreading allows concurrent execution of multiple threads within a single process. Threads share the same memory space, enabling efficient resource usage. Benefits include improved performance, responsive UI, and better CPU utilization. Challenges include race conditions, deadlocks, and synchronization issues.

Q8. What is a deadlock? How can it be prevented?

Deadlock occurs when two or more processes are waiting for each other to release resources. Prevention methods: 1) Resource ordering - request resources in a fixed order, 2) Lock timeout - acquire locks with timeout, 3) Deadlock detection - periodically check and break deadlocks, 4) Resource allocation graph - track resource allocation.

Q9. Explain REST API and its principles.

REST (Representational State Transfer) is an architectural style for web services. Principles: Stateless (no client context stored), Client-Server separation, Cacheable responses, Uniform interface (standard HTTP methods), Layered system, Code on demand (optional). Uses HTTP methods: GET, POST, PUT, DELETE.

Q10. What is the difference between process and thread?

Process is an independent program with its own memory space. Thread is a lightweight unit within a process sharing memory. Processes are isolated and communicate via IPC; threads share memory and can access each other's data directly. Context switching is faster for threads than processes.

HR Interview Questions

Q1. Tell me about yourself.

Start with your name and educational background, then mention your technical skills and interests. Highlight relevant projects and achievements. End with your career goals and why you're interested in Cognizant. Keep it concise (1-2 minutes) and professional.

Q2. Why do you want to join Cognizant?

Mention Cognizant's global presence, diverse projects, and learning opportunities. Highlight their work culture, digital transformation initiatives, and career growth potential. Show that you've researched the company: 'Cognizant's work in digital solutions and cloud services aligns with my interest in emerging technologies.'

Q3. What are your strengths and weaknesses?

Strengths: Quick learner, team player, problem-solving ability, adaptability. Be specific with examples. Weakness: Choose something genuine but not critical, and show how you're improving. Example: 'I sometimes focus too much on details, but I've learned to prioritize tasks and meet deadlines.'

Q4. Are you willing to relocate to any Cognizant office in India?

Yes, flexibility is valued. Say: 'I am open to relocation as it would be a great opportunity to explore new places and gain diverse work experience. I understand that the IT industry requires flexibility, and I'm ready for it.'

Q5. Do you have any questions for us?

Always ask thoughtful questions: 'What does the training program look like for freshers?', 'What technologies will I be working with?', 'What are the growth opportunities for high performers?', 'Can you tell me about the team I would be joining?'

Q6. Where do you see yourself in 5 years?

Show ambition while being realistic: 'In 5 years, I see myself as a senior developer with expertise in specific technologies. I hope to lead projects and mentor juniors while continuously learning new skills. I want to grow with Cognizant and contribute to meaningful projects.'

Q7. How do you handle pressure and tight deadlines?

Describe your approach: 'I prioritize tasks, break down work into manageable parts, and focus on the most critical items first. I communicate proactively with team members if I need help. During my college projects, I successfully managed multiple deadlines by maintaining a schedule.'

Q8. Are you aware of the service agreement/bond?

Cognizant typically has a service agreement for freshers (usually 2 years). Say: 'Yes, I am aware of the service agreement and I am fully committed to fulfilling my obligation. I view this as an opportunity to learn and grow within the company.'

Coding Questions

Q1. Write a program to check if a string is a palindrome.

function isPalindrome(str) {
  const cleaned = str.toLowerCase().replace(/[^a-z0-9]/g, '');
  return cleaned === cleaned.split('').reverse().join('');
}

// Example: isPalindrome("A man a plan a canal Panama") // true

Q2. Write a program to find the factorial of a number.

function factorial(n) {
  if (n <= 1) return 1;
  return n * factorial(n - 1);
}

// Iterative version
function factorialIterative(n) {
  let result = 1;
  for (let i = 2; i <= n; i++) {
    result *= i;
  }
  return result;
}

Q3. Write a SQL query to find the second highest salary from an Employee table.

-- Method 1: Using LIMIT and OFFSET
SELECT DISTINCT salary 
FROM Employee 
ORDER BY salary DESC 
LIMIT 1 OFFSET 1;

-- Method 2: Using subquery
SELECT MAX(salary) 
FROM Employee 
WHERE salary < (SELECT MAX(salary) FROM Employee);

Q4. Write a program to reverse a linked list.

class Node {
  constructor(data) {
    this.data = data;
    this.next = null;
  }
}

function reverseLinkedList(head) {
  let prev = null;
  let current = head;
  
  while (current !== null) {
    let next = current.next;
    current.next = prev;
    prev = current;
    current = next;
  }
  
  return prev;
}

Q5. Write a program to find duplicates in an array.

function findDuplicates(arr) {
  const seen = new Set();
  const duplicates = [];
  
  for (const item of arr) {
    if (seen.has(item)) {
      if (!duplicates.includes(item)) {
        duplicates.push(item);
      }
    } else {
      seen.add(item);
    }
  }
  
  return duplicates;
}

// Example: findDuplicates([1, 2, 3, 2, 4, 3]) // [2, 3]

Prepare More