Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
  • Home
  • Blog
  • General
  • 52+ Top Cognizant Interview Questions and Answers to Prepare for in 2025

52+ Top Cognizant Interview Questions and Answers to Prepare for in 2025

By Sriram

Updated on Feb 26, 2025 | 36 min read

Share:

Cognizant is a global leader in IT services, consulting, and business processes, offering services like software development, cloud computing, AI, and enterprise solutions. With roles like software developers and system engineers, Cognizant looks for candidates with strong knowledge in programming, data structures, and problem-solving.

To succeed, you need to master basic concepts, excel in aptitude tests, and effectively navigate the HR round to secure a position at this company. In this blog, you’ll explore some common Cognizant interview questions covering technical, aptitude, and HR rounds.

Cognizant Interview Questions for Freshers: Key Questions to Prepare

Freshers attending Cognizant interview questions must prepare for questions on data structures, algorithms, OOPs concepts, and database management systems.

Here are some common Cognizant interview questions and answers for freshers.

1. What are pointers in C, and how do they work?

A: Pointers in C are variables that store the memory address of another variable. Unlike regular variables, which store data, pointers store the memory location where the data is held.

Here’s how pointers work:

  • Declaration: A pointer is declared using the asterisk (*) symbol. For example, int *ptr; declares a pointer to an integer.
  • Dereferencing: To access the value stored at the address the pointer is pointing to, we use the dereferencing operator (*). For example, *ptr = 10; assigns the value 10 to the variable pointed to by ptr.
  • Address-of operator: To get the variable’s address, use the address-of operator (&). For example, ptr = &x; makes ptr point to the memory address of variable x.

Example:

int x = 10;
int *ptr = &x;  // ptr stores the address of x
printf("%d", *ptr);  // Outputs: 10, dereferencing ptr gives the value of x

Enroll in Online Software Development Courses today to master key C programming concepts. Gain the confidence to tackle technical interviews.

2. Can you explain memory leaks and how to prevent them?

A: A memory leak takes place when a program allocates memory dynamically (using malloc()) but fails to deallocate it (using free()). This causes the memory to remain allocated when it is no longer needed, leading to system crashes.

Here’s how you can prevent them:

  • Always pair malloc() with free(): Every time you allocate memory dynamically, ensure you free it when it’s no longer needed.
  • Use smart pointers (in C++): In C++, use RAII (Resource Acquisition Is Initialization) techniques with smart pointers like std::unique_ptr or std::shared_ptr to manage memory automatically.
  • Tools: Use tools like Valgrind or AddressSanitizer to check for memory leaks in your program.

Example:

int *ptr = (int*)malloc(sizeof(int));  // Dynamically allocated memory
*ptr = 10;
free(ptr);  // Memory is freed after use

3. How does garbage collection work? Which algorithm is commonly used?

A: Garbage collection automatically identifies and reclaims memory that is no longer in use, freeing the programmer from manual memory management. This is particularly significant in high-level programming languages like Java or Python.

Mark-and-Sweep is the most common garbage collection algorithm used. It involves two phases:

  • Mark Phase: The garbage collector identifies which objects are still reachable (i.e., in use).
  • Sweep Phase: The algorithm frees the memory occupied by objects that are no longer reachable.

Example:

public class GarbageCollectionExample {
    public static void main(String[] args) {
        String str = new String("Hello");
        str = null;  // Now the string object is eligible for garbage collection
    }
}

Garbage Collection in Java is automatically handled by the JVM, where the Mark-and-Sweep algorithm is commonly used. JVM implementation could differ across different systems.

In modern JVMs, garbage collection divides memory into the young generation (short-lived objects) and old generation (long-lived objects).

The G1 garbage collector optimizes collection by managing both generations, minimizing pause times while reclaiming memory efficiently.

4. What is a dangling pointer, and why is it problematic?

A: A dangling pointer continues to point to a memory location even after the memory it points to has been deallocated (freed). This can happen if you call free() on memory and then try to access it using a pointer that hasn't been set to NULL.

Here’s why it can be problematic:

  • Undefined behavior: Dereferencing a dangling pointer leads to undefined behavior, which causes the program to crash, produce incorrect results, or even cause security vulnerabilities (e.g., memory corruption).
  • Hard to Debug: Dangling pointers are difficult to identify, leading to unpredictable bugs in the program.

Prevention: After freeing memory, always set the pointer to NULL to prevent accidental dereferencing.

Example:

int *ptr = (int*)malloc(sizeof(int));
free(ptr);  // Memory freed
// ptr is now a dangling pointer, avoid dereferencing it
ptr = NULL;  // Nullify the pointer to prevent dangling

5. What is the mark and sweep algorithm?

A: The Mark-and-Sweep algorithm is a two-phase garbage collection technique used to reclaim memory in managed languages.

Here’s how it works:

  • Mark Phase: Starting from the "root" references (like stack variables), the garbage collector "marks" all objects that are reachable.
  • Sweep Phase: After marking all reachable objects, the garbage collector scans memory and deallocates all the objects that were not marked (i.e., those that are no longer referenced).

Example:

Mark Phase: [Root] --> [A] --> [B] --> [C]  (Marked)
Sweep Phase: [Unmarked objects are freed, like D and E]

Learn the crucial aspect of problem-solving in computer science using algorithms like Mark and Sweep. Join the free course on Data Structures & Algorithms now!

6. How does recursion function in programming?

A: A recursion function function calls itself directly or indirectly to solve a problem. It’s used in problems that can be divided into smaller sub-problems of the same type.

Here’s how the recursion function works:

  • Base Case: Every recursive function needs to have a base case that stops the recursion, preventing infinite loops.
  • Recursive Case: The function solves a smaller version of the problem and calls itself to solve even smaller sub-problems.

Example: Calculating factorial using recursion:

int factorial(int n) {
    if (n == 0 || n == 1)  // Base case
        return 1;
    else
        return n * factorial(n - 1);  // Recursive case
}

Also Read: Recursion in Data Structures: Types, Algorithms, and Applications

7. What are data types, and why are they important?

A: Data types specify which type of value a variable can hold. They define what operations can be performed on the data and how much space it occupies in memory.

Common data include int, char, float, bool, varchar, etc.

Here’s why they are important:

  • Memory Management: Data types determine how much memory is allocated to store the value.
  • Data Integrity: Using appropriate data types ensures that only valid operations can be performed on a value. For example, trying to divide an integer by a string would be invalid.
  • Performance: Correct data types can improve performance by reducing unnecessary conversions and optimizing memory usage.

Example:

int age = 25;         // Integer
float height = 5.8;   // Floating-point number
char grade = 'A';     // Character

Also Read: Data Types in C and C++ Explained for Beginners

8. What is the purpose of malloc in C?

A: The malloc (memory allocation) function in C allocates a specified amount of bytes of memory dynamically during program execution. The allocated memory remains in use until it is explicitly deallocated using free().

Here’s the purpose of malloc:

  • Dynamic Memory Allocation: It allows you to allocate memory at runtime based on the program’s needs instead of allocating a fixed amount of memory at compile-time.
  • Flexibility: You can allocate memory for arrays, structures, or other data structures whose size is not known in advance.
  • Avoiding Stack Overflow: Local variables in functions are typically stored in the stack, which has a limited size. By using malloc to allocate memory on the heap, you avoid exceeding the stack's limits,
  • Create Complex Data Structures: Using malloc makes it easier to handle complex data structures like queues, stacks, and dynamically sized matrices.

9. How would you define a string in programming?

A: String is a sequence of characters that represent text, such as names, messages, or any other kind of textual data. 

In C, strings are shown as arrays of characters, with the last character being a special null character ('\0') to indicate the end of the string.

Example:

char name[] = "Jay";  // String in C, null-terminated
printf("%s", name);    // Output: Jay

10. What is an integer, and how is it used in coding?

A: An integer is a whole number, which can be either positive, negative, or zero, without any decimal points.

Here’s how integer is used in coding:

  • Loop Control: Integers are widely used in loop control structures like for, while, and do-while loops. The loop counter is typically an integer.
  • Flags or Status Indicators: Integers can represent flags or status indicators, where certain integer values (like 0 and 1) represent different states. 
  • Arithmetic Operations: Integers are used in mathematical operations like addition, subtraction, multiplication, and division.
  • Handling Time and Dates: Integers are used in many applications related to time and dates, such as tracking seconds, minutes, or hours. 

Example: 

int a = 10;     // Declare an integer
int b = 5;
int result = a + b;  // Add two integers
printf("%d", result);  // Output: 15

11. How do arrays store and manage data?

A:  An array is a collection of elements of the same data type stored in continuous memory locations. It is indexed by a set of integers starting from 0.

Here’s how arrays store and manage data:

  • Memory Allocation: Arrays reserve a block of memory large enough to store all elements. The size of an array must be known at compile-time (for static arrays) or dynamically allocated (for dynamic arrays).
  • Fixing a Size: In C, static arrays have a fixed size that is determined at compile-time. Once an array is defined, its size cannot be changed during runtime.
  • Accessing Elements: You can access Array elements using their index, e.g., arr[0] accesses the first element.

Example:

int arr[5] = {1, 2, 3, 4, 5};  // Array of 5 integers
printf("%d", arr[2]);  // Accesses the 3rd element, Output: 3

12. What are primitive data types in Java?

A: In Java, primitive data types represent the most basic data types that hold simple values. They are not objects and directly hold the data value.

Here are the different primitive data types:

  • byte: 8-bit signed integer.
  • short: 16-bit signed integer.
  • int: 32-bit signed integer.
  • long: 64-bit signed integer.
  • float: Single-precision 32-bit floating point.
  • double: Double-precision 64-bit floating point.
  • char: 16-bit Unicode character.
  • boolean: Represents true or false.

Also Read: Data Types in Java: Primitive & Non-Primitive Data Types

13. How does int differ from Integer in Java?

A: In Java, int is a primitive data type, while Integer is a wrapper class that provides methods to work with integer values as objects.

Here’s how they differ:

int integer
Primitive data type. Wrapper class for the primitive int.
Takes 4 bytes of memory. Takes more memory (typically 16 bytes) due to being an object.
The default value is 0. The default value is null (since it's an object).
Cannot participate in autoboxing/unboxing directly. Supports autoboxing (converting int to Integer) and unboxing (converting Integer to int).
Faster because it’s a primitive type. Slower due to object overhead and method calls.

14. What is a bootloader, and why is it needed?

A: A bootloader is a small program that runs when a device is powered on. It loads the operating system into memory and starts it.

GRUB (Grand Unified Bootloader) is a popular bootloader used in many Linux-based systems.

Here’s why a bootloader is needed:

  • Initial Setup: It initializes the system hardware and sets up memory and peripheral devices.
  • Loading the OS: It loads the operating system kernel into memory, making sure that the system can begin running.
  • System Integrity: It checks for system integrity and ensures that the OS is loaded correctly.

15. How does an interpreter differ from a compiler?

A: An interpreter translates and executes code line-by-line at runtime, whereas a compiler translates the entire code into machine code before execution.

Here’s how the interpreter and compiler differ:

Interpreter Compiler
Executes the code directly, interpreting one statement at a time. Translates the entire program into machine code first and then executes it.
Slower because it interprets code line-by-line. Faster execution as code is already translated to machine code.
Stops execution at the first error encountered. Detects all errors at once, after compilation.
Lower memory consumption during execution. Higher memory usage due to storage of compiled code.
Used in Python, JavaScript, and Ruby. Used in C and C++.

Also Read: Compiler vs Interpreter: Difference Between Compiler and Interpreter

16. What are the key principles of Object-Oriented Programming (OOP)?

A: The key principles of Object-Oriented Programming (OOP) include:

  • EncapsulationHides the object’s internal state from the outside world, only allowing access via methods. In a bank account class, the balance is encapsulated and can only be modified via deposit or withdrawal methods.
  • Inheritance: Allows one class (subclass) to obtain the properties and methods of another class (parent class).  In an online shopping system, a Product class might include general properties like name and price, while subclasses like Clothing inherit those properties.
  • Polymorphism: Classes can respond to the same method call in different ways. It allows different types of objects to be treated as objects of a common superclass. Polymorphism is used in large systems like banking software or e-commerce systems.
  • Abstraction: Hiding the complex implementation details and showing only the necessary features to the user. For instance, in a payment gateway, users only need to input payment details and the rest is handled by the system.

Explore OOP principles like Abstraction, Encapsulation, Inheritance, and Polymorphism to enhance your coding skills and build scalable Java applications. Join the free course on Java Object-oriented Programming now!

17. How does Abstraction simplify code structure?

A: Abstraction simplifies code by focusing on the essential features while hiding unnecessary details. This allows programmers to interact with high-level interfaces without worrying about the underlying complexity.

Here’s how it simplifies code structure:

  • Reduces complexity: By hiding unnecessary implementation details.
  • Improves maintainability: Changes in the underlying implementation do not affect the rest of the system.
  • Improves reusability: Abstract classes and interfaces can be reused across different classes.

Example:

abstract class Animal {
    abstract void sound(); // Abstract method
}

class Dog extends Animal {
    void sound() {
        System.out.println("Bark");
    }
}

Also Read: Abstraction in Java: Types of Abstraction Explained Examples

18. What is Inheritance, and how is it used in Java?

A: Inheritance allows one class (child/subclass) to obtain the fields and methods of another class (parent/superclass). 

Here’s how it is used in Java:

In Java, inheritance is implemented using the extends keyword, where a subclass inherits the properties and methods of the superclass.

Example

 class Animal {
    void eat() {
        System.out.println("Eating");
    }
}

class Dog extends Animal {  // Dog inherits from Animal
    void bark() {
        System.out.println("Barking");
    }
}

public class Main {
    public static void main(String[] args) {
        Dog d = new Dog();
        d.eat();  // Inherited method
        d.bark(); // Dog-specific method
    }
}

Also Read: What are the Types of Inheritance in Java? Examples and Tips to Master Inheritance

19. How does Encapsulation improve security in OOP?

A: Encapsulation restricts direct access to an object's internal state and only allows it to be modified through well-defined methods. This protects the integrity of the data and prevents unauthorized access or modification.

Here’s how it improves security in OOP:

  • Data Hiding: The internal data is hidden from outside access and can only be accessed or modified through public getter and setter methods.
  • Control over data: The methods can include checks and validation, ensuring that only valid data is assigned.
  • Improved Security: Sensitive information can be protected by controlling access through private or protected fields.

Example:

class Account {
    private double balance;  // Private data, cannot be accessed directly

    // Getter method
    public double getBalance() {
        return balance;
    }

    // Setter method with validation
    public void setBalance(double balance) {
        if (balance >= 0) {
            this.balance = balance;
        }
    }
}

20. What is Polymorphism, and where is it applied?

A: Polymorphism allows different classes to implement the same method in different ways, enabling a single interface to represent multiple forms of behavior.

Here’s where Polymorphism is applied:

  • Inheritance Hierarchies: Allows subclasses to provide their own implementation of methods given in the parent class
  • Interfaces and Abstract Classes: Allows different classes to implement or extend the same interface with their specific behavior.
  • Collections and Data Structures: Commonly used when dealing with collections of objects.
  • Dynamic Method Dispatch: Allows a method to be invoked on an object without knowing its exact class at compile time. 

Example:

class Animal {
    void sound() {
        System.out.println("Animal sound");
    }
}

class Dog extends Animal {
    void sound() {
        System.out.println("Bark");
    }
}

public class Main {
    public static void main(String[] args) {
        Animal myDog = new Dog();
        myDog.sound(); // Will call the Dog class's sound method (runtime polymorphism)
    }
}

Also Read: What is Polymorphism in Python? Polymorphism Explained with Examples

The questions for freshers will cover topics like OOP (Inheritance), data structures (Arrays), and data types (int). Now, let's take a look at Cognizant interview questions for experienced professionals.

Cognizant Interview Questions and Answers for Experienced Professionals

Advanced questions for the interview will focus on expertise in data structures (stack), database design (Oracle), and systems design (multitasking).

Here are some Cognizant interview questions and answers for experienced professionals.

1. What is a Linked List, and how is it implemented?

A: Linked List is a linear data structure containing a sequence of elements called nodes. Each node consists of a data element (value) and a reference (or link) to the next node in the sequence.

The nodes are not stored in contiguous memory locations, and hence, there’s no need for a fixed size as in arrays.

Here’s how it is implemented:

You can implement a linked list using a Node class or struct. Each node contains the data and a pointer to the next node.

Example: Implementation in Python:

class Node:
    def __init__(self, data):
        self.data = data
        self.next = None

class LinkedList:
    def __init__(self):
        self.head = None

    def append(self, data):
        new_node = Node(data)
        if not self.head:
            self.head = new_node
        else:
            current = self.head
            while current.next:
                current = current.next
            current.next = new_node

2. How can you reverse a Linked List? Explain the approach.

A: Reversing a linked list involves reversing the direction of the links between the nodes so the head becomes the tail and vice versa. 

Here’s how you can reverse Linked List:

  • Initialize three pointers:
    • prev (set to None initially).
    • current (set to the head of the list).
    • next_node (to store the next node temporarily).
  • Traverse the linked list, and for each node:
    • Store the next node (next_node = current.next).
    • Change the current node's next pointer to the previous node (current.next = prev).
  • Move prev to the current node, and move current to the next node (current = next_node).
    • Once the traversal is complete, the prev pointer will be at the new head of the reversed list.

Edge Cases:

  • If the linked list is empty (i.e., the head is null or None), there’s nothing to reverse, so the list should remain empty. 
  • If the linked list contains only one node, it should remain unchanged after reversal.

Example: Implementation in Python:

def reverse_linked_list(head):
    if head is None:  # Empty list case
        return None
    
    prev = None
    current = head
  
    while current:  # Loop to reverse the links
        next_node = current.next  # Store the next node
        current.next = prev  # Reverse the link
        prev = current  # Move prev and current one step forward
        current = next_node
    
    return prev  # New head of the reversed list

3. What is a Queue? Provide a real-world example of its usage.

A: Queue is a type of linear data structure that is based on the FIFO (First In, First Out) principle. The element added first will be the first one to be removed. It is used for managing tasks that need to be processed in the order they arrive.

Here’s a real-world example of its usage:

Consider a printer queue in an office environment:

  • When multiple print job requests are sent to a printer, they are placed in a queue.
  • The printer processes the first job that was submitted and removes it from the queue, and the next job is processed after completing the first.

Example: Implementation in Python

from collections import deque

# Initialize queue and perform enqueue (append) and dequeue (popleft)
queue = deque(["job1", "job2", "job3"])  # Enqueue jobs

# Dequeue jobs and print results
print(f"Dequeued: {queue.popleft()}")  # Dequeues "job1"
print(f"Queue after dequeue: {queue}")

print(f"Dequeued: {queue.popleft()}")  # Dequeues "job2"
print(f"Queue after dequeue: {queue}")

Explanation:

  • Initialization and Enqueue: The queue is initialized with ["job1", "job2", "job3"], which combines the enqueue operation into a single line.
  • Dequeue: The popleft() method is used to remove and return the element at the front of the queue. After each dequeue, the current state of the queue is printed.

4. What is a Doubly Linked List, and how does it differ from a standard Linked List?

A: Doubly Linked List is a variation of the standard linked list in which each node consists of two pointers: one pointing to the next node (next) and another to the previous node (prev).

Here’s how it differs from the standard linked list:

Standard Linked List Doubly Linked List
Traversal in one way (forward) Traversal in both ways (forward and backward)
Only 1 pointer per node. 2 pointers per node.
Needs less memory Needs more memory
Slower for deletion from the middle Faster for deletion from the middle
Suitable when only forward traversal is required. Suitable when both forward and backward traversals are required.

5. What is the difference between push() and pop() in data structures?

A: The push() and pop() are associated with stack data structures and represent adding an element (push) and removing an element (pop).

Here’s the difference between push and pop:

push() pop()
Increases the stack size by adding a new element. Decreases the stack size by removing the top element.
Does not return a value (just adds the element). Returns the element that was removed from the stack.
Follows Last In, First Out (LIFO). Follows Last In, First Out (LIFO)
Used when pushing new data onto the stack for storage. Used when retrieving and processing the most recent data.

Also Read: How to Implement Stacks in Data Structure? Stack Operations Explained

6. What is a Graph, and how is it used in real life?

A: Graph is a non-linear data structure that is made up of a collection of nodes (or vertices) and edges connecting pairs of nodes. In graph networks, nodes represent entities, and edges represent relationships between them.

Here’s how they are used in real life:

  • Social Networks: Graphs help model and analyze relationships in social media platforms (e.g., Facebook, Twitter).
  • Web Crawling: The web can be represented as a graph where web pages are vertices, and hyperlinks between them are edges.
  • Route Planning: In GPS navigation systems, locations (cities, intersections) are vertices, and roads (paths between locations) are edges. Algorithms like Dijkstra’s are used to find the shortest path between two locations.
  • Recommendation Systems: In e-commerce or content streaming platforms (e.g., Amazon, Netflix), products or movies are nodes, and user preferences are edges. 

7. How do Stacks and Arrays differ?

A: A stack is a linear data structure in which elements are added and removed from only one end. An array is a collection of elements stored in contiguous memory.

Here’s how they differ:

Stacks  Arrays
Linear data structures with a Last In, First Out (LIFO) order of operations. Linear data structures with elements stored in contiguous memory.
Operations include push(), pop (), and peek(). Operations include insert(), delete(), and update().
Access is restricted to the top element only. Random access is allowed at any index.
Used in scenarios requiring order reversal, such as function call stacks, especially in systems programming or recursive function calls. Used for storing collections of elements where fast access by index is required.

8. What is a Stack, and how does it operate?

A: A Stack is a linear data structure that follows the LIFO (Last In, First Out) principle. The last element added to the stack is the first one to be removed.

Here’s how it operates:

  • push(item): Adds an item to the top of the stack.
  • pop(): Removes the item from the top of the stack and returns it.
  • peek(): Returns the top item without removing it.
  • is_empty(): Checks whether the stack is empty.

Use Case: Stacks are commonly used in managing function calls in recursion.

Example: Implementation in Python:

 class Stack:
    def __init__(self):
        self.stack = []

    def push(self, item):
        self.stack.append(item)

    def pop(self):
        if not self.is_empty():
            return self.stack.pop()
        return None

    def peek(self):
        return self.stack[-1] if self.stack else None

    def is_empty(self):
        return len(self.stack) == 0

# Usage
s = Stack()
s.push(10)
s.push(20)
print(s.pop())  # Output: 20

9. What is a Binary Tree, and where is it applied?

A: Binary Tree is a tree data structure where each node consists of at most two children, referred to as the left child and the right child. The topmost node of a binary tree is called the root.

Here are the applications of a binary tree:

  • Binary Search Tree (BST)A binary tree where nodes follow the left node < parent < right node property. It’s used for efficient searching and sorting.
  • Expression Parsing: Used in parsing mathematical expressions (like converting infix to postfix).
  • Heap Structures: Binary heaps are used in priority queues (min-heaps and max-heaps).
  • Decision Trees: Used in machine learning algorithms for classification and regression tasks.

Also Read: Guide to Decision Tree Algorithm: Applications, Pros & Cons & Example

10. Write a program to implement search functionality in a Binary Search Tree.

A: A Binary Search Tree (BST) is a binary tree where each node follows the property: left child < parent node < right child.

Here’s a Python program for its implementation:

class Node:
    def __init__(self, key):
        self.left = None
        self.right = None
        self.value = key

class BinarySearchTree:
    def __init__(self):
        self.root = None

    def insert(self, key):
        if self.root is None:
            self.root = Node(key)
        else:
            self._insert(self.root, key)

    def _insert(self, node, key):
        if key < node.value:
            if node.left is None:
                node.left = Node(key)
            else:
                self._insert(node.left, key)
        else:
            if node.right is None:
                node.right = Node(key)
            else:
                self._insert(node.right, key)

    def search(self, key):
        return self._search(self.root, key)

    def _search(self, node, key):
        # Base cases: node is null or key is present at the node
        if node is None or node.value == key:
            return node
        # Key is greater than node's value, search in the right subtree
        if key > node.value:
            return self._search(node.right, key)
        # Key is smaller, search in the left subtree
        return self._search(node.left, key)

# Example usage
bst = BinarySearchTree()
bst.insert(50)
bst.insert(30)
bst.insert(70)
bst.insert(20)
bst.insert(40)
bst.insert(60)
bst.insert(80)

result = bst.search(40)
if result:
    print(f"Found {result.value}")
else:
    print("Not found")

11. What is Dynamic Programming, and how does it improve efficiency?

A: Dynamic Programming (DP) is an algorithmic technique used to solve problems by converting them down into simpler subproblems.

Here’s how it improves efficiency:

  • Overlapping Subproblems: In many problems (e.g., shortest path problems), DP solves each subproblem once and stores its result (in a table or array), which can be reused when needed.
  • Optimal Substructure: The solution to a problem can be constructed from the solutions to its subproblems.
  • Non-recursive Calculations: DP allows you to solve problems iteratively (tabulation), eliminating the need for deep recursion.
  • Improves Accuracy: DP removes the possibility of overlooking overlapping subproblems or missing out on suboptimal choices during problem-solving.

12. What is the Traveling Salesman Problem, and why is it important?

A: The Traveling Salesman Problem (TSP) is an optimization problem where a salesman must visit a set of cities and return to the starting point. The goal is to minimize the total travel distance.

Here’s why it is important:

  • Real-World Applications: TSP is used in logistics, manufacturing, and routing problems, such as delivery truck routing.
  • Economic Impact: Solving TSP efficiently can lead to significant cost savings in transportation and logistics.
  • Algorithmic Research: TSP serves as a benchmark problem in optimization, helping to develop and test new algorithms and techniques.

13. Explain the concept of Merge Sort and its advantages.

A: Merge Sort is a divide and conquer algorithm. It divides the input array into two halves, sorts each half recursively, and then merges the sorted halves to give the final sorted array.

Here are its advantages:

  • Stable Sort: Elements with equal value retain their relative order.
  • Time Complexity: Merge Sort has a time complexity of O(n log n), which is more efficient than other sorting algorithms like QuickSort.
  • Parallelizable: The divide-and-conquer nature makes Merge Sort suitable for parallel execution on multiple processors.
  • External Sorting: Useful for external sorting, where the data being sorted doesn't fit into memory and must be processed in chunks.

14. Can you implement the Bubble Sort algorithm?

A: Bubble Sort is a comparison-based sorting algorithm. It works by going through the list, comparing adjacent elements, and swapping them if they are in the wrong order. The pass through the list is performed until the list is sorted.

Implementation in Python:

def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        swapped = False
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]  # Swap if the element is greater
                swapped = True
        if not swapped:
            break  # If no swaps occurred, the list is sorted
    return arr

# Example usage
arr = [64, 34, 25, 12, 22, 11, 90]
sorted_arr = bubble_sort(arr)
print("Sorted array:", sorted_arr)

15. What is Preemptive Multitasking, and how does it work?

A: In Preemptive Multitasking, the operating system (OS) allocates a fixed time slice to each process. When a process’s time slice expires, the OS forcibly removes it from the CPU and gives another process a chance to run.

Here’s how it works:

  • The OS uses a scheduler to determine which process gets the CPU next.
  • Each process is given a time slice or quantum. Once this time is over, the process is preempted, and the scheduler switches to another process.
  • This allows for concurrent execution of multiple processes, even if the system only has one CPU.

Use case: Modern operating systems (e.g., Windows) use preemptive multitasking to ensure smooth execution of background processes like system updates.

16. What are the steps involved in starting an Oracle database?

A: Here are the steps involved in starting an Oracle database:

  • Set Environment Variables: Make sure the following are properly set:
    • ORACLE_HOME: This points to the directory where Oracle is installed.
    • ORACLE_SID: This specifies the unique name of the Oracle database instance.
    • PATH: Ensure the Oracle bin directory is included in your system's PATH.

Command: 

export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1

export ORACLE_SID=ORCL

export PATH=$ORACLE_HOME/bin:$PATH

  • Start the Oracle Listener:

Commandlsnrctl start

  • Start the Database Instance:

Commandsqlplus / as sysdba (log into Oracle as SYSDBA), then run startup

  • Mount the Database:

Command: startup mount

  • Open the Database:

Commandalter database open;

  • Verify the Database:

Command: select status from v$instance;

17. What is RAC (Real Application Clusters) in Oracle databases?

A: RAC (Real Application Clusters) allows multiple instances of a database to run on different servers but access the same database storage.

RAC’s high availability and scalability make it useful for e-commerce systems and banking systems.

Here are its key features:

  • Shared Storage: Multiple database instances access a shared storage (disk subsystem) that contains the database files.
  • Fault Tolerance: If one server fails, the other servers can continue to process database requests without interruption.
  • Load Balancing: Requests are distributed across the available database instances to optimize resource utilization.

18. What is Split Brain Syndrome, and how does it affect database management?

A: Split Brain Syndrome occurs in a clustered system (like Oracle RAC) when multiple nodes assume they are the primary (master) node due to communication failure. 

Here’s how it affects the database management:

  • Data Corruption: Both clusters can modify the same data, resulting in inconsistencies.
  • Availability Problems: The system may become unavailable or unreliable due to conflicting changes being made.
  • Transaction Conflicts: Both clusters may attempt to commit conflicting transactions, leading to transaction rollback or failure.
  • Performance Degradation: The overhead of resolving conflicts after the split can lead to slower performance.

Prevention: Implement quorum-based voting mechanisms or heartbeat checks to ensure that only one node gets access to the primary database.

19. How does Depth First Search (DFS) work in a Binary Tree?

A: Depth First Search (DFS) is a traversal algorithm that goes as far down a branch of the tree as possible before backtracking. It uses a stack or recursion to remember the path to backtrack.

Here’s how DFS works in a binary tree:

  • DFS starts from the root node and follows the left subtree first, then explores the right subtree.
  • The algorithm uses recursion or a stack to remember the path, ensuring it can backtrack when it reaches a leaf node or an already visited node.
  • The traversal continues until all nodes are visited.

Implementation:

  • Using Recursion: The system’s call stack is used to handle the traversal. Each recursive call processes one node and moves on to the left or right child nodes, backtracking once the children are fully explored.

Example

class Node:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

def dfs_recursive(root):
    if root is None:
        return
    print(root.value)  # Visit the node
    dfs_recursive(root.left)  # Explore the left subtree
    dfs_recursive(root.right)  # Explore the right subtree

# Example usage:
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)

dfs_recursive(root)
  • Using Explicit Stack: You push nodes onto the stack as you encounter them and pop nodes off when backtracking. This method mimics the system call stack but is explicit.

Example:

class Node:
    def __init__(self, value):
        self.value = value
        self.left = None
        self.right = None

def dfs_stack(root):
    if root is None:
        return
    stack = [root]
    while stack:
        node = stack.pop()  # Pop the top node from the stack
        print(node.value)  # Visit the node
        if node.right:  # Push right child to stack
            stack.append(node.right)
        if node.left:  # Push left child to stack
            stack.append(node.left)

# Example usage:
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)

dfs_stack(root)

20. Swap two numbers without using a third variable.

A: To swap two numbers without using a third variable, you can use arithmetic operations or bitwise XOR. 

Here’s a Python implementation:

a = 5
b = 10

a = a ^ b  # a becomes 15
b = a ^ b  # b becomes 5 (15 ^ 10)
a = a ^ b  # a becomes 10 (15 ^ 5)

print(a, b)  # Output: 10 5

The interview questions for experts will cover important algorithms like DFS and Binary Search, as well as the basic workings of database systems like Oracle. Now, let’s look at some Cognizant interview questions in the aptitude section.

Cognizant Aptitude & Logical Reasoning Questions and Answers

Concepts like time and distance, number systems, and pattern recognition are commonly asked in the aptitude section of Cognizant interview questions.

Here are some simple Cognizant interview questions and answers in the aptitude round.

1. A train travels a certain distance in 2 hours. If the train's speed is 45 km/h, how far will the train travel in that time?

A: Imagine you are planning a trip where coordination between different legs of the journey is important. By estimating your travel time, you can be better prepared and plan accordingly.

You are given,

  • Speed of the train = 45 km/h
  • Time = 2 hours

To find the distance, we use the formula:

Distance = Speed × Time

Distance = 45  × 2 = 90 KM

So, the train will travel 90 kilometers in 2 hours.

2. Solve this logarithm-based mathematical equation. What is log101000?

A: We know that log101000 is asking for the exponent to which 10 must be raised to get 1000.

103 = 1000

Hence, log101000 is 3.

3. The sum of two numbers is 10, and their product is 24. What are the two numbers?

A: Let the two numbers be x and y.

  • Sum: x + y = 10
  • Product: x × y = 24

x and y must satisfy both these conditions.

Let's think of pairs of numbers that add up to 10:

  • 6 and 4

Now, check if their product is 24:

  • 6 × 4 = 24

So, the two numbers are 6 and 4.

4. A train is moving at 60 km/h. The train is 120 meters long. How long will it take to pass a man walking at 6 km/h in the same direction?

A: Relative speed of the train and man: 60 km/h − 6 km/h = 54 km/h

Convert to meters per second: 54km/h = 54×1000/3600=15m/s

Time taken to pass the man:

Time=Distance/Speed = 120/15 =8s

Time taken to pass the man: 8 seconds

5. You have 1000 rupees. One person gets twice the amount of the second person, the third person gets three times, and the fourth person gets four times the second person’s amount. How much does each person get?

A: Let the second person get x rupees.

First person gets 2x, third person gets 3x, and fourth person gets 4x.

Total money is 1000, so:

2x + x + 3x + 4x  = 1000 

10x = 1000

x = 100

Hence, 

1st person gets 2x = 2 X 100 = 200 rupee

2nd person gets x = 100 rupees

3rd person gets 3x = 3 X 100 = 300 rupees

4th person get 4x = 4 X 100 = 400 rupees

6. A gardener has 12 saplings to plant in a straight line, and the total space available is 30 meters. How far apart should the saplings be?

A: There are 11 gaps between 12 saplings.

The distance between each sapling:

Distance=3011 =  2.73 m (approx)

Hence, saplings should be about 2.73 meters apart.

7. If APPLE is coded as BQPSF, what would ORANGE be coded as?

A: Here’s the breakdown of the pattern:

A → B: Shifted forward by 1.

P → Q: Shifted forward by 1.

P → P: No change.

L → S: Shifted forward by 7.

E → F: Shifted forward by 1.

For ORANGE:

O → shift forward by 1: P

R → shift forward by 1: S

A → No change: A

N → shift forward by 7: U

G → shift forward by 1: H

E → shift forward by 1: F

Hence, ORANGE can be coded as PSAUHF.

8. A person starts at point A. They walk 10 meters North, then 5 meters East, then 10 meters South, and finally 5 meters West. Where is the person now?

A: 

  • Start at point A.
  • Walk 10 meters North: New position is 10 meters North of A.
  • Walk 5 meters East: New position is 5 meters East of the previous point.
  • Walk 10 meters South: New position is back to the same level as the starting point (because 10 meters North and 10 meters South cancel each other out).
  • Walk 5 meters West: New position is back to the starting point.

Hence, the person is back to Point A.

9. What is the largest number less than 100 that is divisible by 7?

A: To find the largest number divisible by 7 less than 100:

Divide 100 by 7 = 100/7=14.2857

The largest integer less than 14.2857 is 14.

Multiplying 14 by 7, we get 14 X 7 = 98

Hence, the largest number less than 100 divisible by 7 is 98.

10. What is the sum of the cubes of 2, 3, and 4?

A: To find the sum of the cubes of the numbers, we calculate the cube of each number first.

Cube of 2: 23=8

Cube of 3: 33=27

Cube of 4: 43=64

Hence, the sum of the cubes is 8 + 27 + 64 = 99

11. What is the smallest divisor of 48 that is greater than 10?

A: To find the smallest divisor of 48 that is greater than 10, we first list the divisors of 48:

The divisors of 48 are: 1, 2, 3 , 4 , 6 , 8 , 12 , 16 , 24 , 48

The smallest divisor among 12, 16, 24, and 48 is 12

Hence, the smallest divisor of 48 greater than 10 is 12.

12. Answer in a word

  • What is the opposite of VINDICTIVE?

A: FORGIVING

  • Identify the antonym of PECULIAR.

A: NORMAL

  • Choose the correct antonym for PREJUDICE.

A: IMPARTIAL

  • Complete the analogy: Odometer : Mileage :: Compass : ?

A: Direction

  • Find the correct word pair: Marathon : Race :: Hibernation : ?

A: Sleep

  • Identify the correct relationship: Window : Pane :: Book : ?

A: Page

  • Choose the correct analogy: Cup : Coffee :: Bowl : ?

A: Soup

Aptitude questions will cover concepts like time and distance, number system, and profits and losses, which are typically asked in interviews. Now, let’s explore Cognizant interview questions and answers asked in the HR round.

Cognizant HR Interview Questions for Freshers & Experts

Questions in the HR round are phrased to check your personality, ability to handle challenges, and fit within the company’s culture. You may also expect questions about past experiences, teamwork, leadership, and future career aspirations.

Here are some Cognizant interview questions and answers for the HR round:

1. How would you introduce yourself in a concise yet compelling way?

A: While introducing yourself, focus on your professional background, key achievements, and relevant skills, and align them with the company’s requirements.

Example:

Hi, I’m Raj, a software developer with 5 years of experience specializing in full-stack development. I’ve worked on projects using technologies like React and Node.js, and I’m passionate about building scalable applications. In my last role at TCS, I helped reduce page load times by 30%, significantly improving user experience.”

Also Read: How to Introduce Yourself in an Interview: Tips for a Great First Impression

2. What steps do you take to keep learning and improving your skills?

A: Show the interviewers that you are proactive about learning and show your commitment to staying updated with industry trends. Mention specific resources or strategies that have worked for you.

Example

“I regularly take online courses on platforms like upGrad to enhance my technical knowledge, particularly in areas like cloud computing and machine learning. I’m part of a developer community where we share insights and collaborate on projects.”

3. What are your top strengths and qualifications that make you a strong candidate?

A: Identify a few key strengths that are directly relevant to the role. Highlight both technical skills and soft skills.

Example:

“One of my strengths is problem-solving. I enjoy breaking down complex programming challenges into manageable parts and finding efficient solutions. Additionally, I’m a strong communicator, able to work effectively in cross-functional teams.”

4. Where do you see yourself growing within this company if hired?

A: The answer must show your long-term vision and whether your goals align with the company’s growth. Show that you are ambitious and eager to grow within the organization.

Example

“I see myself taking on more leadership responsibilities and mentoring junior developers. I’d love to contribute to innovations that drive the company’s success.” 

5. Share an example of a difficult situation you encountered and how you resolved it.

A: The answer must show your problem-solving and decision-making skills. Focus on a real challenge, your approach to solving it, and the positive outcome.

Example:

“During my previous job, we encountered a significant performance issue with the application just before the deadline. I took the initiative to organize a cross-team troubleshooting session to identify the root cause. After analyzing the code, I identified an inefficient database query and worked with the team to optimize it. The performance improved by 40%, and we were able to deliver a more efficient product.”

6. What drives you to excel in your work?

A: The question must show your motivation and passion. Make sure your answer reflects your commitment to high-quality work and how that aligns with the company’s goals.

Example:

“I’m driven by the opportunity to create meaningful and impactful solutions. Seeing my work positively impact the end-users or the business keeps me motivated. Additionally, the opportunity to grow my skill set and collaborate with a talented team pushes me to give my best every day.”

7. How do you handle pressure and meet deadlines effectively?

A: Your answer must demonstrate how you manage your workload effectively under pressure. Highlight your organizational skills, explain how you prioritize tasks, and, if possible, provide an example.

Example:

“When working under pressure, I break down tasks into manageable chunks. I prioritize tasks based on urgency and impact, and I use tools like project management software to track my progress.” 

8. What interests you about this role, and why do you want to be part of our team?

A: Your answer must show that you’ve researched the company and your goals align with their values. Be specific about what excites you about the role and how your skills will contribute to the team.

Example:

“I’m particularly excited about this role because of the opportunity to work on cloud computing technology and contribute to impactful projects. I admire your company’s focus on AI-based cloud systems, and I believe my background in cloud computing will allow me to make a meaningful contribution.” 

The answers must not only highlight your skills and achievements but also demonstrate your fit for the role. Now, let’s check out the best strategies to crack Cognizant interview questions.

Best Strategies to Succeed in Cognizant Interviews

For the technical and aptitude rounds, practice solving coding problems and aptitude questions, including quantitative aptitude and logical reasoning. 

For the HR round, focus on resume building, highlighting your skills and achievements. Practicing mock interviews and preparing answers for common HR questions will help boost your confidence and improve your communication skills.

Here are some best strategies to tackle cognizant interview questions and answers.

  • Develop Problem-Solving 

Focus on areas like data structures (arrays and lists), algorithms (dynamic programming), object-oriented programming (OOP), and system design.

Example: Learn how to solve a problem like "Find the longest substring without repeating characters".

Discover different tools and frameworks that will help you tackle challenges with precision and insight. Join the free course on Complete Guide to Problem Solving Skills!

  • Increase your speed and Accuracy for Aptitude Round

Learn to solve problems on topics like time and distance, probability, number series, and pattern recognition with a time limit.

Example: If you're given a time and distance problem, practice how to quickly calculate the speed or relative speed between two moving objects.

  • Be Confident in HR Round

Communicate your view properly. Be prepared to discuss your strengths, weaknesses, and why you want to work at Cognizant.

Example: If asked, "Tell me about your strengths," don’t just say you're a “hard worker.” Provide examples, like, "I tend to take ownership of projects, like when I led a group project on XYZ where we successfully met deadlines."

Discover common challenges and build the essential skills needed to express thoughts and opinions effectively. Join the free course on Mastering the Art of Effective Communication.

  • Research about Cognizant

Perform research on Cognizant’s core business areas, recent projects, and their culture. Familiarize yourself with their client list, technologies (e.g., cloud, AI), and recent news.

Example: If asked, "Why do you want to work at Cognizant?" say, "I admire how Cognizant uses emerging technologies like AI and cloud to transform industries”.

  • Teamwork and Collaboration

Don’t forget to emphasize how you work in teams, handle conflicts, and adapt to new technologies or environments.

Example: When asked about handling a conflict, you could explain: "In my last project, there was a difference of opinion. I facilitated a discussion where we blended both ideas to reach a solution that worked for everyone."

Now that you’ve explored some tips to tackle Cognizant interview questions in the HR round, let’s take a look at how to better prepare for Cognizant interviews.

How Can upGrad Help? 

Cognizant interviews assess core concepts (programming), aptitude (logical reasoning), and personality (goals, experiences) to evaluate candidates. Practicing core concepts and soft skills (communication) can be a recipe for success. 

upGrad’s industry-focused courses, real-world projects, and mock interviews will build both technical expertise and interview-ready confidence to crack Cognizant interview.

Here are some courses offered by upGrad:

Unsure which course aligns with your career goals? upGrad offers personalized counseling to help map your learning journey and choose the right path. You can also visit your nearest upGrad offline center for an interactive experience!

Frequently Asked Questions

1. How many rounds of interviews for Cognizant?

2. What is Cognizant famous for?

3. Is there a coding round in the Cognizant interview?

4. Which is the best site to practice coding interviews for Cognizant?

5. Is the aptitude round an elimination round in Cognizant interview?

6. How many candidates are selected for the 3rd round interview?

7. What types of questions are asked for Cognizant interviews?

8. How to tackle aptitude questions in Cognizant interview?

9. How should I prepare for aptitude questions?

10. What happens in Cognizant HR discussion?

11. How do I prepare for HR discussions?

Sriram

181 articles published

Get Free Consultation

+91

By submitting, I accept the T&C and
Privacy Policy

Top Resources

Recommended Programs

Suggested Blogs