Cognizant interview questions

890 questions from 146 interviews · updated from reports 2016-2025

Practise Cognizant-style

About

Cognizant is an IT services and consulting company that helps businesses build, run, and manage software, data, cloud, and business process systems. In India, it often hires entry-level candidates for GenC, GenC Next, and Software Engineer roles across application development, testing, and support.

The roles that come up most are GenC, Software Engineer and GenC Next. This covers 146 candidate interviews reported from 2016 to 2025. Most sat it at entry level (140 of 142 that recorded a level), with 1 internship interviews alongside. Among the 112 that recorded either route, arrivals split between campus drives (87, 78%) and off-campus applications (25, 22%). Most questions fall under CS fundamentals and DSA.

Category
Difficulty
Round

Interview questions

Q. What is the difference between an abstract class and an interface in Java?

asked 5xeasyOOPTechnical2021-2025

Ans. An abstract class is a partial base class, while an interface is mainly a contract a class agrees to implement. An abstract class can hold instance state, constructors, and concrete methods, but a class can extend only one. A class can implement multiple interfaces, which is useful for defining shared capabilities.

Q. Explain different types of SQL joins.

asked 4xeasySQLTechnical2020-2025

Ans. SQL joins combine rows from related tables using a matching condition, usually a key. INNER JOIN returns only matching rows. LEFT JOIN returns all rows from the left table plus matches from the right. RIGHT JOIN is the reverse. FULL OUTER JOIN returns all rows from both sides. CROSS JOIN returns every combination of rows.

Q. What is the Singleton design pattern?

asked 4xeasyDesign patternsTechnical2022-2025

Ans. The Singleton pattern ensures a class has exactly one instance and provides a global access point to it. It is usually implemented with a private constructor and a static method or property returning the instance. The key detail is thread safety, especially if the instance is created lazily in a multi-threaded program.

Q. What is the difference between a list and a tuple in Python?

asked 4xeasyPythonTechnical2021-2024

Ans. A list is mutable, while a tuple is immutable. Lists can have items added, removed, or changed after creation, but tuples cannot. Lists use square brackets and tuples use parentheses. Tuples are often used for fixed collections of values and can be hashable if all their elements are hashable.

Q. Write a program to check whether a given string is a palindrome.

asked 4xeasyStringsTechnical2019-2022

Ans. Use two pointers, one at the start of the string and one at the end, and compare characters while moving inward. If any pair differs, it is not a palindrome; if the pointers meet or cross, it is. This uses no extra data structure and runs in O(n) time with O(1) space.

Q. Write a program to check whether a given string or number is a palindrome.

asked 4xeasyStringsTechnical2021-2023

Ans. Use two pointers, one at the start and one at the end, and compare characters while moving inward. For a number, either convert it to a string or reverse its digits and compare with the original. The string approach uses constant extra data and runs in O(n) time.

Q. Reverse a singly linked list.

asked 3xmediumLinked listsTechnical2016-2019

Ans. Reverse it by walking through the list once and redirecting each node’s next pointer to the previous node. Keep three pointers: previous, current, and next, so you do not lose the remaining list. At the end, previous becomes the new head. Time is O(n), space is O(1).

Q. Explain OOPS concepts in Java

asked 3xeasyOOPTechnical2021-2023

Ans. OOPS in Java means organising code around objects that combine data and behaviour. The main concepts are encapsulation, inheritance, polymorphism, and abstraction. Encapsulation hides state using classes and access modifiers. Inheritance reuses behaviour. Polymorphism allows one interface to have many implementations. Abstraction exposes essential behaviour while hiding implementation details.

Q. Explain ACID properties in DBMS

asked 3xeasyDBMSTechnical2020-2024

Ans. ACID properties are the guarantees that make database transactions reliable: Atomicity, Consistency, Isolation and Durability. Atomicity means all or nothing, Consistency keeps valid rules, Isolation prevents concurrent transactions interfering, and Durability ensures committed changes survive crashes. They are essential for correctness in systems handling critical data.

Q. Explain exception handling in Java.

asked 3xeasyException handlingTechnical2022-2023

Ans. Exception handling in Java is a mechanism for dealing with runtime errors without abruptly stopping normal program flow. Risky code is placed in a try block, errors are handled in catch blocks, and cleanup goes in finally. Java has checked exceptions, which must be caught or declared, and unchecked exceptions.

Q. Difference between JDK, JRE, and JVM

asked 3xeasyOOPTechnical2020-2023

Ans. JVM runs Java bytecode, JRE provides the environment to run Java applications, and JDK provides tools to develop them. The key difference is scope: JVM is the execution engine, JRE includes JVM plus runtime libraries, and JDK includes JRE plus developer tools such as the compiler, debugger, and packaging utilities.

Q. What is SDLC (Software Development Life Cycle)?

asked 3xeasySoftware engineeringHR, Technical2017-2019

Ans. SDLC is a structured process for planning, building, testing, deploying, and maintaining software. It gives teams a clear path from requirements to release, reducing risk and improving quality. Common stages include requirement analysis, design, implementation, testing, deployment, and maintenance, often repeated in agile or iterative models.

Q. What is inheritance in object-oriented programming?

asked 3xeasyOOPTechnical2023-2025

Ans. Inheritance is an object-oriented programming feature where one class derives from another class and reuses or extends its fields and methods. The derived class, often called a subclass, can add new behaviour or override existing behaviour, while the base class defines shared functionality. It supports code reuse and represents “is a” relationships.

Q. Explain Object-Oriented Programming (OOPS) concepts.

asked 3xeasyOOPHR, Technical2019-2024

Ans. Object-Oriented Programming organises software around objects that combine data and behaviour. A class is a blueprint, and an object is an instance of it. The main concepts are encapsulation to hide internal state, abstraction to expose essentials, inheritance to reuse and extend behaviour, and polymorphism to use one interface with different implementations.

Q. What is the difference between DDL and DML commands?

asked 3xeasyDBMSTechnical2024

Ans. DDL commands define or change the database structure, while DML commands read or change the data stored in that structure. DDL includes CREATE, ALTER, DROP and TRUNCATE. DML includes SELECT, INSERT, UPDATE and DELETE. The key difference is that DDL affects schema objects, whereas DML affects rows of data.

Q. Write a program to calculate the factorial of a number

asked 3xeasyMathOnline test, Technical2020-2024

Ans. Calculate factorial by starting with result 1 and multiplying it by every integer from 2 up to n. Use a simple loop and one numeric variable, so no extra data structure is needed. Return 1 for n equal to 0 or 1, reject negative input, and the time complexity is O(n).

Q. What is the difference between DELETE and TRUNCATE in SQL?

asked 3xeasySQLTechnical2019-2025

Ans. DELETE removes selected rows and can use a WHERE clause, while TRUNCATE removes all rows from a table. DELETE is usually row logged, can fire delete triggers, and is slower for large tables. TRUNCATE deallocates data pages, is faster, often resets identity values, and cannot be used when referenced by foreign keys.

Q. What is the difference between UNION and UNION ALL in SQL?

asked 3xeasySQLTechnical2021-2023

Ans. UNION combines the results of two queries and removes duplicate rows, while UNION ALL combines the results and keeps all rows, including duplicates. UNION usually costs more because the database must compare or sort results to eliminate duplicates. Both require matching column counts and compatible data types.

Q. Write a program to count the number of vowels in a given string.

asked 3xeasyStringsTechnical2019-2021

Ans. Scan the string once and count each character that is a vowel. Store the vowels in a set, usually a, e, i, o, u, and optionally their uppercase forms, so membership checks are constant time. Increment a counter for each match. The time complexity is O(n) and the space complexity is O(1).

Q. Explain Java 8 features

asked 2xmediumOOPTechnical2023-2024

Ans. Java 8 introduced lambdas, functional interfaces, the Stream API, default and static methods in interfaces, Optional, the new java.time date and time API, and CompletableFuture improvements. The most important change is lambdas plus streams, which allow concise functional-style processing of collections with operations like map, filter and reduce.

Q. Explain the Factory design pattern.

asked 2xmediumDesign patternsTechnical2024-2025

Ans. The Factory design pattern creates objects without exposing the exact creation logic to the client. Instead of calling constructors directly, the client asks a factory for an object, usually through a common interface or base class. This reduces coupling and makes it easier to add or change concrete classes.

Q. Explain Java OOPS concepts with code examples.

asked 2xmediumOOPTechnical2021

Ans. Java OOP is based on encapsulation, inheritance, polymorphism and abstraction. Encapsulation keeps fields private and exposes methods. Inheritance lets a class extend another. Polymorphism lets the same method call behave differently for subclasses. Abstraction hides details using interfaces or abstract classes. For example, Animal, Dog and Cat can model these ideas.

Q. Describe a recently faced difficult situation and how you handled it

asked 2xmediumConflict resolutionTechnical2020-2021

Ans. Pick a recent work situation with real pressure, such as a missed deadline, conflict, client issue, or mistake. Emphasise your role, the specific actions you took, and the outcome. Interviewers listen for ownership, calm judgement, communication, problem solving, and what you learned or changed afterwards.

Q. In a bank there are three types of coins: 1 rupee, 3 rupee, and 5 rupee in the ratio 3:4:5. The total value is Rs 1450. Find the total number of coins.

asked 2xmediumRatioTechnical2021-2023

Ans. There is no whole-number solution. Let the numbers of 1, 3 and 5 rupee coins be 3x, 4x and 5x. Their value is 3x + 12x + 25x = 40x = 1450, so x = 36.25. The total would be 12x = 435, but the coin counts are fractional.

Q. Reverse a string in one line

asked 2xeasyStringsTechnical2024

Ans. Use slicing with a negative step to return the string in reverse in one line. This creates a new string containing the characters from end to start, since strings are immutable. The data structure is the string itself, and the time complexity is linear in the string length.

Q. Why do we use COMMIT in SQL?

asked 2xeasyDBMSTechnical2024

Ans. COMMIT is used to make all changes in the current transaction permanent in the database. Until a transaction is committed, its inserts, updates, or deletes can usually be rolled back. COMMIT confirms the work, makes it visible according to the database’s isolation rules, and helps preserve consistency and durability.

Q. Write SQL queries using JOINs

asked 2xeasySQLTechnical2021-2024

Ans. Use JOINs by selecting the needed columns, naming the main table, joining related tables with ON conditions that match primary and foreign keys, then filtering with WHERE if needed. The key detail is choosing the correct join type: INNER for matching rows, LEFT for keeping all left-side rows, and FULL for keeping both sides.

Q. Remove duplicates from an array

asked 2xeasyArraysTechnical2024

Ans. Use a hash set to track values already seen, then scan the array once and keep only the first occurrence of each value. This preserves the original order if you write kept values to a result array. The time complexity is O(n), and the extra space complexity is O(n).

Q. Difference between set and tuple

asked 2xeasyOOPTechnical2024

Ans. A tuple is an ordered, immutable sequence, while a set is an unordered collection of unique elements. A tuple can contain duplicates and supports indexing and slicing. A set removes duplicates and is mainly used for fast membership tests, unions, intersections and differences, but it does not preserve positional access.

Q. What is the Virtual DOM in React?

asked 2xeasyFrontendTechnical2021-2025

Ans. The Virtual DOM in React is a lightweight JavaScript representation of the real DOM. When state or props change, React creates a new Virtual DOM tree, compares it with the previous one using reconciliation, and updates only the necessary parts of the real DOM, which makes UI updates more efficient.

Q. What is the pass keyword in Python?

asked 2xeasyOOPTechnical2024

Ans. The pass keyword in Python is a null statement that does nothing when executed. It is used as a placeholder where syntax requires a statement, such as an empty function, class, loop, or conditional block. It lets the program remain valid while you add the real implementation later.

Q. In which OSI layer does HTML belong?

asked 2xeasyNetworkingTechnical2021-2023

Ans. HTML belongs to the Application layer, Layer 7 of the OSI model. It is a markup language used by web applications to structure content, typically delivered over HTTP or HTTPS, which are also Application layer protocols. Lower layers handle transport, routing, framing, and physical transmission.

Q. Write an SQL query for an INNER JOIN.

asked 2xeasySQLTechnical2023-2024

Ans. Use an INNER JOIN by selecting columns from the first table, joining the second table, and matching related keys in the ON condition, such as customer id in both tables. The important detail is that it returns only rows where the join condition matches in both tables, excluding unmatched rows.

Q. What is the __init__ method in Python?

asked 2xeasyOOPTechnical2024

Ans. The __init__ method in Python is a special method called automatically when a new object is created from a class. It initialises the object’s state, usually by assigning values to instance attributes. Its first parameter is self, which refers to the new object, and it should not explicitly return a value.

Q. Remove duplicates from a list in one line

asked 2xeasyArraysTechnical2024

Ans. Use a set to track seen values, or in Python use the ordered dictionary idiom if you need a one line expression that preserves order. The key detail is whether order matters: a plain set removes duplicates but may reorder items. This is typically linear time with linear extra space.

Q. What is the difference between C++ and Java?

asked 2xeasyOOPTechnical2020-2022

Ans. C++ is a compiled systems language with manual memory control, while Java is a managed language that runs on the JVM with automatic garbage collection. The most important difference is control versus portability: C++ gives closer access to hardware and performance tuning, while Java offers safer memory handling and easier cross-platform execution.

Q. Explain the difference between HTTP and HTTPS

asked 2xeasyNetworkingTechnical2019-2024

Ans. HTTP sends data between a browser and a server in plain text, while HTTPS uses TLS to encrypt that data. The important difference is security: HTTPS protects confidentiality, helps verify the server’s identity using certificates, and prevents tampering in transit. HTTP commonly uses port 80, and HTTPS uses port 443.

Q. What are Primary Memory and Secondary Memory?

asked 2xeasyMemoryTechnical2021-2022

Ans. Primary memory is the main memory directly accessed by the CPU, such as RAM and cache, while secondary memory is long-term storage such as SSDs, hard disks, and optical media. The key difference is that primary memory is faster and usually volatile, whereas secondary memory is slower but non-volatile and persistent.

Q. What is the difference between PL/SQL and SQL?

asked 2xeasySQLTechnical2025

Ans. SQL is a declarative language used to query and manipulate relational data, while PL/SQL is Oracle’s procedural extension to SQL. The key difference is that SQL runs single data operations, whereas PL/SQL can group SQL with variables, loops, conditions, exceptions and stored procedures for application logic.

Q. Write a program to find the GCD of two numbers

asked 2xeasyMathOnline test2020

Ans. Use the Euclidean algorithm: repeatedly replace the larger number by the remainder when it is divided by the smaller number, until the remainder becomes zero. The last non-zero number is the GCD. It needs only a few integer variables, no extra data structure, and runs in O(log min(a, b)) time.

Q. Explain method overloading and method overriding

asked 2xeasyOOPTechnical2019

Ans. Method overloading means defining multiple methods with the same name but different parameter lists in the same class. Method overriding means a subclass provides its own implementation of a method already defined in its superclass. Overloading is resolved at compile time, while overriding uses runtime polymorphism.

Q. Write a program to generate the Fibonacci series

asked 2xeasyRecursionTechnical2023-2024

Ans. Generate the Fibonacci series by starting with 0 and 1, then repeatedly adding the previous two numbers to get the next term until the required count is reached. Store the values in an array or list if they must be returned. The time complexity is O(n), with O(n) space, or O(1) if printed directly.

Q. What is the main difference between Java and C++?

asked 2xeasyOOPTechnical2021-2023

Ans. Java runs on the JVM with automatic memory management, while C++ is compiled to native machine code and gives more direct control over memory. The key practical difference is that Java favours portability and safety through garbage collection, whereas C++ favours performance and low-level control but requires more care from the programmer.

Q. What is the difference between Java and JavaScript?

asked 2xeasyOOPTechnical2024-2025

Ans. Java and JavaScript are different languages with different runtimes and use cases. Java is a statically typed, class-based language compiled to bytecode and run on the JVM, often used for backend systems and Android. JavaScript is dynamically typed and mainly used for web interactivity, running in browsers and Node.js.

Q. Write a basic program to print numbers from 1 to 10

asked 2xeasyBasic programmingTechnical2019

Ans. Use a simple loop that starts at 1, prints the current number, and increments until it reaches 10. No special data structure is needed because each value is generated directly. The loop runs a fixed 10 times, so the time complexity is O(1), with O(1) space.

Q. Explain Object-Oriented Programming concepts in Java

asked 2xeasyOOPTechnical2019-2024

Ans. Object-oriented programming in Java organises code around objects that combine data and behaviour. The main concepts are encapsulation, inheritance, polymorphism and abstraction. Encapsulation hides state behind methods, inheritance reuses and extends classes, polymorphism lets one interface have many implementations, and abstraction exposes essential behaviour while hiding details. Interfaces and classes support these ideas.

Q. Explain encapsulation and the static keyword in Java

asked 2xeasyOOPTechnical2022

Ans. Encapsulation is hiding an object’s internal state and exposing controlled access through methods, usually using private fields and public getters or setters. The static keyword makes a member belong to the class rather than an instance. Static fields are shared by all objects, and static methods can be called without creating an object.

Q. Basic DSA problem (easy level) asked in the online test

asked 2xeasyGeneralOnline test2023

Ans. Use the simplest data structure that matches the operation needed, usually an array, string, hash set, or hash map. For easy online test problems, aim for one pass where possible, track only required values, handle edge cases like empty input, and state the time complexity, usually O(n).

Q. Explain the Object-Oriented Programming (OOP) concepts.

asked 2xeasyOOPTechnical2020-2024

Ans. Object-Oriented Programming models software as objects that combine data and behaviour. The main concepts are encapsulation, which hides internal state; abstraction, which exposes only needed details; inheritance, which reuses and extends existing classes; and polymorphism, which lets different objects respond to the same interface in their own way.

Q. Explain the four pillars of Object-Oriented Programming

asked 2xeasyOOPTechnical2022-2024

Ans. The four pillars of object-oriented programming are encapsulation, abstraction, inheritance, and polymorphism. Encapsulation hides internal state behind methods. Abstraction exposes only essential behaviour. Inheritance lets classes reuse and extend other classes. Polymorphism lets different objects be treated through the same interface while providing their own behaviour.

Q. A can do a work in 12 days and B can do the same work in 18 days. In how many days will they complete the work together?

asked 2xeasyTime and workTechnical2021-2023

Ans. They will complete the work together in 7.2 days, or 7 days and 1/5 of a day. Add their daily work rates: A does 1/12 of the work per day and B does 1/18. Together, they do 1/12 + 1/18 = 5/36 per day. Time = 36/5 = 7.2 days.

Q. Logical reasoning questions testing analytical thinking.

asked 2xunknownLogical reasoningOnline test2019-2023

Ans. Identify the rule or relationship before trying to answer. Separate facts from assumptions, look for patterns, categories, sequences, cause and effect, or exclusions. Work step by step, eliminate impossible options, and check that the remaining answer fits every condition. If stuck, test simple examples rather than guessing.

Q. Given expression a = 2; evaluate a * a++.

asked 1xmediumOperatorsTechnical2021

Ans. There is no single answer without the language. In Java or C#, operands are evaluated left to right, so left a is 2, a++ also contributes 2, then a becomes 3. The expression value is 4. In C or C++, reading and modifying a without sequencing gives undefined behaviour.

Q. How does a search engine work on the front end?

asked 1xmediumWeb architectureHR2024

Ans. A search engine front end captures the query, validates and normalises it, sends it to a search API, then renders ranked results, filters, pagination, snippets and loading or error states. The most important detail is responsiveness: use debouncing, caching and cancellation of stale requests so fast typing does not flood the backend or show outdated results.

Q. How do you provide security to a web application?

asked 1xmediumApplication securityTechnical2024

Ans. Secure a web application with defence in depth: HTTPS everywhere, strong authentication, least privilege authorisation, input validation, output encoding, CSRF protection, secure session cookies, rate limiting, and safe secret storage. The most important detail is to treat all user input as untrusted and enforce checks on the server, not only in the browser.

Q. Tell me an incident which shows your leadership skills.

asked 1xmediumLeadershipHR2023

Ans. Pick a real incident where you influenced others without relying only on authority, especially under pressure or ambiguity. Emphasise the problem, your specific actions, how you aligned people, handled conflict, and delivered a measurable result. Interviewers listen for ownership, judgement, communication, resilience, and whether others trusted your direction.

Q. Describe a time when you handled a conflict within a team.

asked 1xmediumConflict resolutionHR2023

Ans. Choose a real conflict where you helped move the team towards a decision, not one where you blame others. Emphasise listening, understanding both sides, staying calm, and focusing on shared goals. Interviewers listen for maturity, communication, ownership, and a practical outcome, such as a clearer plan or repaired working relationship.

Q. How can a biased coin be used to generate unbiased outcomes?

asked 1xmediumProbabilityTechnical2016

Ans. Toss the biased coin twice. If the result is heads then tails, output 1. If it is tails then heads, output 0. If both tosses match, ignore them and try again. This is fair because heads then tails and tails then heads both have probability p(1-p), assuming independent tosses.

Q. How would you ensure efficient query retrieval in a graph database?

asked 1xmediumDatabasesTechnical2017

Ans. I would ensure efficient retrieval by modelling relationships for the main access patterns, indexing high-cardinality lookup properties, and keeping traversals selective and bounded. The most important detail is to start queries from indexed nodes, then traverse only the necessary edge types and depths, because graph performance depends mainly on avoiding broad scans.

Q. Solve the 3-liter and 5-liter water jug puzzle to measure a specific quantity.

asked 1xmediumLogical reasoningTechnical2025

Ans. Measure 4 litres by using the 5-litre jug as the final container. Fill the 5-litre jug and pour into the 3-litre jug, leaving 2 litres. Empty the 3-litre jug, pour the 2 litres into it, then fill the 5-litre jug again and top up the 3-litre jug. The 5-litre jug now has 4 litres.

Showing 60 of 890 questions. Ranked by how often the same question came back across interviews.

Practise a Cognizant-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does Cognizant ask?

Candidate interviews most often cover CS fundamentals (69%) and DSA (19%).

How many rounds does Cognizant interview have?

Candidate interviews show an average of 3.0 rounds per experience, with a typical sequence of Online test → Technical → HR. Individual interview paths can vary.

Is the Cognizant interview hard?

Among questions with a recorded difficulty, the mix is easy 72%, medium 27%, hard 1%.