Cognizant GenC Interview Experience
276
Nov 24, 2025

On 26th August 2025, I appeared for Cognizant’s interview for the Programmer Analyst Trainee / .NET Developer role. The interview was structured, practical, and focused on both fundamentals and problem-solving. Here is how my experience went:

🟣 1. Difference Between Abstract Class and Interface

The interviewer began by testing my object-oriented concepts.

I explained that:

Abstract Class

Can have both abstract and non-abstract methods.

Supports constructors, concrete methods, and variables with any access modifier.

Used when classes share a common base behavior.

Interface

All methods are abstract by default (in older Java versions) and public.

Classes can implement multiple interfaces, enabling multiple inheritance.

Best used for capability or contract-based designs.

The interviewer appreciated that I explained with real examples like
"Animal as abstract class, Runnable as interface."

🟣 2. Palindrome Code

I was asked to write a simple palindrome checker.

I wrote:

boolean isPalindrome(String s) {
int i = 0, j = s.length() - 1;
while (i < j) {
if (s.charAt(i) != s.charAt(j))
return false;
i++;
j--;
}
return true;
}

I also explained the logic clearly.

🟣 3. Prime Number Code

Next, they asked for code to check if a number is prime.

I wrote:

boolean isPrime(int n) {
if (n <= 1) return false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) return false;
}
return true;
}

I also explained the optimization using i*i <= n.

🟣 4. JUnit

They asked basic questions like:

What is JUnit?

Why do we use unit testing?

What is an annotation?

Difference between @Before, @After, @Test.

I explained that JUnit is a Java unit-testing framework and talked about:

@Test → marks a test method

assertEquals, assertTrue

Test-driven development

Importance of testing small modules independently

🟣 5. DDL, DML, TCL Commands

I listed examples:

DDL (Data Definition Language)

CREATE

ALTER

DROP

TRUNCATE

DML (Data Manipulation Language)

SELECT

INSERT

UPDATE

DELETE

TCL (Transaction Control Language)

COMMIT

ROLLBACK

SAVEPOINT

I also explained how TCL is used for transaction management.

🟣 6. Second Largest Record Without Using LIMIT

They asked a SQL query to fetch the 2nd largest salary from a table.

I answered:

SELECT MAX(salary)
FROM employees
WHERE salary < (SELECT MAX(salary) FROM employees);

They were satisfied because it avoids LIMIT and works in all SQL engines.

🟣 7. Puzzle: Measure 4 Litres Using 3L and 5L Containers

This was a classic water jug puzzle.

I explained the steps:

Fill 5L jug → (5,0)

Pour from 5L to 3L → (2,3)

Empty 3L jug → (2,0)

Pour remaining 2L into 3L jug → (0,2)

Fill 5L jug again → (5,2)

Pour from 5L to fill the 3L → (4,3)

Now we have exactly 4 litres in the 5L jug.

I also explained reasoning and state transitions.

🟣 8. System Design Questions on My Project

They asked about:

Architecture of my project

How I handled APIs

Database schema

How I ensured scalability

Error handling & logging

How many users it can support

Security measures

I explained:

High-level architecture

Role of controllers, services, database

Use of caching

Why I chose particular technologies

How I ensured modularity

They appreciated my clarity and practical approach.

⭐ Final Outcome

The interview was smooth and technically strong. The interviewer appreciated my clarity, coding confidence, and system design explanations. Overall, it was a great experience and strengthened my confidence in both backend concepts and logical thinking.

Comments (1)