Comprehensive collection of technical, HR, and coding questions asked in Cognizant interviews for freshers.
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.
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.
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.
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.
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).
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.
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.
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.
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.
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.
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.
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.'
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.'
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.'
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?'
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.'
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.'
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.'
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") // truefunction 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;
}-- 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);
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;
}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]