- Blog Categories
- Software Development
- Data Science
- AI/ML
- Marketing
- General
- MBA
- Management
- Legal
- Software Development Projects and Ideas
- 12 Computer Science Project Ideas
- 28 Beginner Software Projects
- Top 10 Engineering Project Ideas
- Top 10 Easy Final Year Projects
- Top 10 Mini Projects for Engineers
- 25 Best Django Project Ideas
- Top 20 MERN Stack Project Ideas
- Top 12 Real Time Projects
- Top 6 Major CSE Projects
- 12 Robotics Projects for All Levels
- Java Programming Concepts
- Abstract Class in Java and Methods
- Constructor Overloading in Java
- StringBuffer vs StringBuilder
- Java Identifiers: Syntax & Examples
- Types of Variables in Java Explained
- Composition in Java: Examples
- Append in Java: Implementation
- Loose Coupling vs Tight Coupling
- Integrity Constraints in DBMS
- Different Types of Operators Explained
- Career and Interview Preparation in IT
- Top 14 IT Courses for Jobs
- Top 20 Highest Paying Languages
- 23 Top CS Interview Q&A
- Best IT Jobs without Coding
- Software Engineer Salary in India
- 44 Agile Methodology Interview Q&A
- 10 Software Engineering Challenges
- Top 15 Tech's Daily Life Impact
- 10 Best Backends for React
- Cloud Computing Reference Models
- Web Development and Security
- Find Installed NPM Version
- Install Specific NPM Package Version
- Make API Calls in Angular
- Install Bootstrap in Angular
- Use Axios in React: Guide
- StrictMode in React: Usage
- 75 Cyber Security Research Topics
- Top 7 Languages for Ethical Hacking
- Top 20 Docker Commands
- Advantages of OOP
- Data Science Projects and Applications
- 42 Python Project Ideas for Beginners
- 13 Data Science Project Ideas
- 13 Data Structure Project Ideas
- 12 Real-World Python Applications
- Python Banking Project
- Data Science Course Eligibility
- Association Rule Mining Overview
- Cluster Analysis in Data Mining
- Classification in Data Mining
- KDD Process in Data Mining
- Data Structures and Algorithms
- Binary Tree Types Explained
- Binary Search Algorithm
- Sorting in Data Structure
- Binary Tree in Data Structure
- Binary Tree vs Binary Search Tree
- Recursion in Data Structure
- Data Structure Search Methods: Explained
- Binary Tree Interview Q&A
- Linear vs Binary Search
- Priority Queue Overview
- Python Programming and Tools
- Top 30 Python Pattern Programs
- List vs Tuple
- Python Free Online Course
- Method Overriding in Python
- Top 21 Python Developer Skills
- Reverse a Number in Python
- Switch Case Functions in Python
- Info Retrieval System Overview
- Reverse a Number in Python
- Real-World Python Applications
- Data Science Careers and Comparisons
- Data Analyst Salary in India
- Data Scientist Salary in India
- Free Excel Certification Course
- Actuary Salary in India
- Data Analyst Interview Guide
- Pandas Interview Guide
- Tableau Filters Explained
- Data Mining Techniques Overview
- Data Analytics Lifecycle Phases
- Data Science Vs Analytics Comparison
- Artificial Intelligence and Machine Learning Projects
- Exciting IoT Project Ideas
- 16 Exciting AI Project Ideas
- 45+ Interesting ML Project Ideas
- Exciting Deep Learning Projects
- 12 Intriguing Linear Regression Projects
- 13 Neural Network Projects
- 5 Exciting Image Processing Projects
- Top 8 Thrilling AWS Projects
- 12 Engaging AI Projects in Python
- NLP Projects for Beginners
- Concepts and Algorithms in AIML
- Basic CNN Architecture Explained
- 6 Types of Regression Models
- Data Preprocessing Steps
- Bagging vs Boosting in ML
- Multinomial Naive Bayes Overview
- Bayesian Network Example
- Bayes Theorem Guide
- Top 10 Dimensionality Reduction Techniques
- Neural Network Step-by-Step Guide
- Technical Guides and Comparisons
- Make a Chatbot in Python
- Compute Square Roots in Python
- Permutation vs Combination
- Image Segmentation Techniques
- Generative AI vs Traditional AI
- AI vs Human Intelligence
- Random Forest vs Decision Tree
- Neural Network Overview
- Perceptron Learning Algorithm
- Selection Sort Algorithm
- Career and Practical Applications in AIML
- AI Salary in India Overview
- Biological Neural Network Basics
- Top 10 AI Challenges
- Production System in AI
- Top 8 Raspberry Pi Alternatives
- Top 8 Open Source Projects
- 14 Raspberry Pi Project Ideas
- 15 MATLAB Project Ideas
- Top 10 Python NLP Libraries
- Naive Bayes Explained
- Digital Marketing Projects and Strategies
- 10 Best Digital Marketing Projects
- 17 Fun Social Media Projects
- Top 6 SEO Project Ideas
- Digital Marketing Case Studies
- Coca-Cola Marketing Strategy
- Nestle Marketing Strategy Analysis
- Zomato Marketing Strategy
- Monetize Instagram Guide
- Become a Successful Instagram Influencer
- 8 Best Lead Generation Techniques
- Digital Marketing Careers and Salaries
- Digital Marketing Salary in India
- Top 10 Highest Paying Marketing Jobs
- Highest Paying Digital Marketing Jobs
- SEO Salary in India
- Content Writer Salary Guide
- Digital Marketing Executive Roles
- Career in Digital Marketing Guide
- Future of Digital Marketing
- MBA in Digital Marketing Overview
- Digital Marketing Techniques and Channels
- 9 Types of Digital Marketing Channels
- Top 10 Benefits of Marketing Branding
- 100 Best YouTube Channel Ideas
- YouTube Earnings in India
- 7 Reasons to Study Digital Marketing
- Top 10 Digital Marketing Objectives
- 10 Best Digital Marketing Blogs
- Top 5 Industries Using Digital Marketing
- Growth of Digital Marketing in India
- Top Career Options in Marketing
- Interview Preparation and Skills
- 73 Google Analytics Interview Q&A
- 56 Social Media Marketing Q&A
- 78 Google AdWords Interview Q&A
- Top 133 SEO Interview Q&A
- 27+ Digital Marketing Q&A
- Digital Marketing Free Course
- Top 9 Skills for PPC Analysts
- Movies with Successful Social Media Campaigns
- Marketing Communication Steps
- Top 10 Reasons to Be an Affiliate Marketer
- Career Options and Paths
- Top 25 Highest Paying Jobs India
- Top 25 Highest Paying Jobs World
- Top 10 Highest Paid Commerce Job
- Career Options After 12th Arts
- Top 7 Commerce Courses Without Maths
- Top 7 Career Options After PCB
- Best Career Options for Commerce
- Career Options After 12th CS
- Top 10 Career Options After 10th
- 8 Best Career Options After BA
- Projects and Academic Pursuits
- 17 Exciting Final Year Projects
- Top 12 Commerce Project Topics
- Top 13 BCA Project Ideas
- Career Options After 12th Science
- Top 15 CS Jobs in India
- 12 Best Career Options After M.Com
- 9 Best Career Options After B.Sc
- 7 Best Career Options After BCA
- 22 Best Career Options After MCA
- 16 Top Career Options After CE
- Courses and Certifications
- 10 Best Job-Oriented Courses
- Best Online Computer Courses
- Top 15 Trending Online Courses
- Top 19 High Salary Certificate Courses
- 21 Best Programming Courses for Jobs
- What is SGPA? Convert to CGPA
- GPA to Percentage Calculator
- Highest Salary Engineering Stream
- 15 Top Career Options After Engineering
- 6 Top Career Options After BBA
- Job Market and Interview Preparation
- Why Should You Be Hired: 5 Answers
- Top 10 Future Career Options
- Top 15 Highest Paid IT Jobs India
- 5 Common Guesstimate Interview Q&A
- Average CEO Salary: Top Paid CEOs
- Career Options in Political Science
- Top 15 Highest Paying Non-IT Jobs
- Cover Letter Examples for Jobs
- Top 5 Highest Paying Freelance Jobs
- Top 10 Highest Paying Companies India
- Career Options and Paths After MBA
- 20 Best Careers After B.Com
- Career Options After MBA Marketing
- Top 14 Careers After MBA In HR
- Top 10 Highest Paying HR Jobs India
- How to Become an Investment Banker
- Career Options After MBA - High Paying
- Scope of MBA in Operations Management
- Best MBA for Working Professionals India
- MBA After BA - Is It Right For You?
- Best Online MBA Courses India
- MBA Project Ideas and Topics
- 11 Exciting MBA HR Project Ideas
- Top 15 MBA Project Ideas
- 18 Exciting MBA Marketing Projects
- MBA Project Ideas: Consumer Behavior
- What is Brand Management?
- What is Holistic Marketing?
- What is Green Marketing?
- Intro to Organizational Behavior Model
- Tech Skills Every MBA Should Learn
- Most Demanding Short Term Courses MBA
- MBA Salary, Resume, and Skills
- MBA Salary in India
- HR Salary in India
- Investment Banker Salary India
- MBA Resume Samples
- Sample SOP for MBA
- Sample SOP for Internship
- 7 Ways MBA Helps Your Career
- Must-have Skills in Sales Career
- 8 Skills MBA Helps You Improve
- Top 20+ SAP FICO Interview Q&A
- MBA Specializations and Comparative Guides
- Why MBA After B.Tech? 5 Reasons
- How to Answer 'Why MBA After Engineering?'
- Why MBA in Finance
- MBA After BSc: 10 Reasons
- Which MBA Specialization to choose?
- Top 10 MBA Specializations
- MBA vs Masters: Which to Choose?
- Benefits of MBA After CA
- 5 Steps to Management Consultant
- 37 Must-Read HR Interview Q&A
- Fundamentals and Theories of Management
- What is Management? Objectives & Functions
- Nature and Scope of Management
- Decision Making in Management
- Management Process: Definition & Functions
- Importance of Management
- What are Motivation Theories?
- Tools of Financial Statement Analysis
- Negotiation Skills: Definition & Benefits
- Career Development in HRM
- Top 20 Must-Have HRM Policies
- Project and Supply Chain Management
- Top 20 Project Management Case Studies
- 10 Innovative Supply Chain Projects
- Latest Management Project Topics
- 10 Project Management Project Ideas
- 6 Types of Supply Chain Models
- Top 10 Advantages of SCM
- Top 10 Supply Chain Books
- What is Project Description?
- Top 10 Project Management Companies
- Best Project Management Courses Online
- Salaries and Career Paths in Management
- Project Manager Salary in India
- Average Product Manager Salary India
- Supply Chain Management Salary India
- Salary After BBA in India
- PGDM Salary in India
- Top 7 Career Options in Management
- CSPO Certification Cost
- Why Choose Product Management?
- Product Management in Pharma
- Product Design in Operations Management
- Industry-Specific Management and Case Studies
- Amazon Business Case Study
- Service Delivery Manager Job
- Product Management Examples
- Product Management in Automobiles
- Product Management in Banking
- Sample SOP for Business Management
- Video Game Design Components
- Top 5 Business Courses India
- Free Management Online Course
- SCM Interview Q&A
- Fundamentals and Types of Law
- Acceptance in Contract Law
- Offer in Contract Law
- 9 Types of Evidence
- Types of Law in India
- Introduction to Contract Law
- Negotiable Instrument Act
- Corporate Tax Basics
- Intellectual Property Law
- Workmen Compensation Explained
- Lawyer vs Advocate Difference
- Law Education and Courses
- LLM Subjects & Syllabus
- Corporate Law Subjects
- LLM Course Duration
- Top 10 Online LLM Courses
- Online LLM Degree
- Step-by-Step Guide to Studying Law
- Top 5 Law Books to Read
- Why Legal Studies?
- Pursuing a Career in Law
- How to Become Lawyer in India
- Career Options and Salaries in Law
- Career Options in Law India
- Corporate Lawyer Salary India
- How To Become a Corporate Lawyer
- Career in Law: Starting, Salary
- Career Opportunities: Corporate Law
- Business Lawyer: Role & Salary Info
- Average Lawyer Salary India
- Top Career Options for Lawyers
- Types of Lawyers in India
- Steps to Become SC Lawyer in India
- Tutorials
- Software Tutorials
- C Tutorials
- Recursion in C: Fibonacci Series
- Checking String Palindromes in C
- Prime Number Program in C
- Implementing Square Root in C
- Matrix Multiplication in C
- Understanding Double Data Type
- Factorial of a Number in C
- Structure of a C Program
- Building a Calculator Program in C
- Compiling C Programs on Linux
- Java Tutorials
- Handling String Input in Java
- Determining Even and Odd Numbers
- Prime Number Checker
- Sorting a String
- User-Defined Exceptions
- Understanding the Thread Life Cycle
- Swapping Two Numbers
- Using Final Classes
- Area of a Triangle
- Skills
- Explore Skills
- Management Skills
- Software Engineering
- JavaScript
- Data Structure
- React.js
- Core Java
- Node.js
- Blockchain
- SQL
- Full stack development
- Devops
- NFT
- BigData
- Cyber Security
- Cloud Computing
- Database Design with MySQL
- Cryptocurrency
- Python
- Digital Marketings
- Advertising
- Influencer Marketing
- Performance Marketing
- Search Engine Marketing
- Email Marketing
- Content Marketing
- Social Media Marketing
- Display Advertising
- Marketing Analytics
- Web Analytics
- Affiliate Marketing
- MBA
- MBA in Finance
- MBA in HR
- MBA in Marketing
- MBA in Business Analytics
- MBA in Operations Management
- MBA in International Business
- MBA in Information Technology
- MBA in Healthcare Management
- MBA In General Management
- MBA in Agriculture
- MBA in Supply Chain Management
- MBA in Entrepreneurship
- MBA in Project Management
- Management Program
- Consumer Behaviour
- Supply Chain Management
- Financial Analytics
- Introduction to Fintech
- Introduction to HR Analytics
- Fundamentals of Communication
- Art of Effective Communication
- Introduction to Research Methodology
- Mastering Sales Technique
- Business Communication
- Fundamentals of Journalism
- Economics Masterclass
- Free Courses
52+ Top Cognizant Interview Questions and Answers to Prepare for in 2025
Updated on Feb 26, 2025 | 36 min read
Share:
Table of Contents
- Cognizant Interview Questions for Freshers: Key Questions to Prepare
- Cognizant Interview Questions and Answers for Experienced Professionals
- Cognizant Aptitude & Logical Reasoning Questions and Answers
- Cognizant HR Interview Questions for Freshers & Experts
- Best Strategies to Succeed in Cognizant Interviews
- How Can upGrad Help?
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:
- Encapsulation: Hides 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.
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: 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: 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: 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: 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: 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:
Command: lsnrctl start
- Start the Database Instance:
Command: sqlplus / as sysdba (log into Oracle as SYSDBA), then run startup
- Mount the Database:
Command: startup mount
- Open the Database:
Command: alter 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".
- 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."
- 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:
- Professional Certificate Program in Cloud Computing and DevOps
- Executive PG Certification in AI-Powered Full Stack Development
- Introduction to Database Design with MySQL
- Complete Guide to Problem Solving Skills
- Learn Basic Python Programming
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?
Get Free Consultation
By submitting, I accept the T&C and
Privacy Policy
Top Resources