Add office photos
Cognizant logo
Engaged Employer

Cognizant

Verified
3.7
based on 50.3k Reviews
Video summary
Proud winner of ABECA 2024 - AmbitionBox Employee Choice Awards
Filter interviews by
Clear (1)

500+ Cognizant Interview Questions and Answers for Freshers

Updated 28 Feb 2025
Popular Designations

Q1. Check for syntax error/logical error and correct the error to get the desired output. void maxReplace(int size,int *inputList) { int i,sum=0; for(i=0;i

Ans.

Fix syntax and logical errors in maxReplace function

  • Change 'o' to '0' in second for loop

  • Replace sum with inputList[i] in second for loop

  • Add a condition to check if inputList[i] is greater than sum in second for loop

  • Print sum instead of inputList[i] in third for loop

View 6 more answers
right arrow

Q2. What is stack? How do you convert a queue to stack?

Ans.

Stack is a data structure that follows LIFO (Last In First Out) principle. Converting a queue to stack requires dequeuing and pushing elements.

  • Stack is a collection of elements with two main operations: push and pop.

  • Push adds an element to the top of the stack, while pop removes the top element.

  • Converting a queue to stack requires dequeuing all elements and pushing them onto a stack.

  • Example: Queue: 1-2-3-4-5, Stack: 5-4-3-2-1

View 4 more answers
right arrow

Q3. What is the difference between structure and class?

Ans.

Structures are value types while classes are reference types.

  • Structures are allocated on stack while classes are allocated on heap.

  • Structures do not support inheritance while classes do.

  • Structures cannot have explicit parameterless constructors while classes can.

  • Structures are used for small data structures while classes are used for larger, more complex objects.

  • Example of structure: struct Point { int x, y; }

  • Example of class: class Person { string name; int age; }

View 2 more answers
right arrow

Q4. Two defined table and fetching data is done one table has 20 records of 20 students another table has 10 student information if i want to pick the common record how to pick?

Ans.

Use SQL JOIN to fetch common records from two tables.

  • Use SQL JOIN to combine the two tables based on a common column (e.g. student ID).

  • Select the columns you want to retrieve from both tables.

  • Use the WHERE clause to filter out the records that are common between the two tables.

Add your answer
right arrow
Discover Cognizant interview dos and don'ts from real experiences

Q5. What is the difference between RDBMS and DBMS? Explain database with a real life example of database.

Ans.

RDBMS is a type of DBMS that uses a relational model to store and manage data.

  • DBMS is a general term for any software that manages data

  • RDBMS uses tables with rows and columns to store data

  • RDBMS enforces relationships between tables using keys

  • Example: MySQL, Oracle, SQL Server

  • Example of a database: a customer database for a retail store

Add your answer
right arrow

Q6. if you promised a customer for the product on a specific day and your company will not be able to give that product on time then how will you convince that customer ?

Ans.

I would apologize for the delay and offer a solution or compensation.

  • Acknowledge the inconvenience caused to the customer

  • Explain the reason for the delay and assure them that steps are being taken to resolve it

  • Offer a solution or compensation to make up for the delay

  • Maintain open communication with the customer throughout the process

Add your answer
right arrow
Are these interview questions helpful?

Q7. If i want to select uncommon records which does not match how to pick?

Ans.

To select uncommon records that do not match, use the NOT IN or NOT EXISTS clause in SQL.

  • Use the NOT IN clause to select records that do not match a specific list of values.

  • Use the NOT EXISTS clause to select records that do not have a matching record in a subquery.

  • Example: SELECT * FROM table_name WHERE column_name NOT IN (value1, value2);

  • Example: SELECT * FROM table1 WHERE NOT EXISTS (SELECT * FROM table2 WHERE table1.id = table2.id);

Add your answer
right arrow

Q8. Technical: SQL queries of join b/w three tables Sorting in descending order c program Full c code to print helloworld Little data structure,dbms Weakness HR: any movies or series recently watched and explain th...

read more
Ans.

The question asks for SQL queries for joining three tables, sorting in descending order in C program, and printing 'Hello, World!' in C.

  • To join three tables in SQL, use the JOIN keyword with appropriate conditions.

  • To sort in descending order in C, use the qsort() function with a custom comparison function.

  • To print 'Hello, World!' in C, use the printf() function with the desired message.

View 1 answer
right arrow
Share interview questions and help millions of jobseekers 🌟
man with laptop

Q9. Why is java platform independent?

Ans.

Java is platform independent due to its bytecode and JVM.

  • Java code is compiled into bytecode which is platform-independent.

  • JVM (Java Virtual Machine) interprets the bytecode and executes it on any platform.

  • This eliminates the need for recompilation of code for different platforms.

  • For example, a Java program compiled on Windows can run on Linux or Mac without any changes.

  • This makes Java highly portable and flexible.

View 11 more answers
right arrow

Q10. Which programming language are you familiar with? what are the datasets in python what is the difference between list and tuple in python? write a program to find number of white spaces in a given string? what...

read more
Ans.

Answering questions related to programming language Python.

  • I am familiar with Python programming language.

  • Datasets in Python include NumPy, Pandas, and SciPy.

  • List is mutable while Tuple is immutable in Python.

  • Program to find number of white spaces in a given string: def count_spaces(string): return string.count(' ')

  • While loop executes a block of code as long as the condition is true, for loop executes a block of code for a specific number of times.

Add your answer
right arrow

Q11. If you have given a 1 kg cake and you have given 3 chance to cut and you have to distribute among 8 people how will you do that? condition is that you have to distribute it equally among 8 people.

Ans.

Divide 1 kg cake equally among 8 people in 3 cuts.

  • Cut the cake into 8 equal pieces using 2 cuts.

  • Stack the pieces and cut them in half using the third cut.

  • Distribute the 16 pieces among 8 people.

View 1 answer
right arrow

Q12. What do you know about OOPS?

Ans.

OOPS stands for Object-Oriented Programming System.

  • OOPS is a programming paradigm that focuses on objects and their interactions.

  • It emphasizes on encapsulation, inheritance, and polymorphism.

  • Encapsulation is the process of hiding implementation details from the user.

  • Inheritance allows a class to inherit properties and methods from another class.

  • Polymorphism allows objects to take on multiple forms or behaviors.

  • Examples of OOPS languages include Java, C++, Python, and Ruby.

View 1 answer
right arrow

Q13. Star Pattern Problem Statement

Display the star pattern for a given positive integer N.

Example:

Input:
N = 4
Output:
 *
***
*****
*******
Explanation:

The dots in the image represent spaces. Align the stars in...read more

Ans.

Display a pyramid star pattern for a given positive integer N with spaces in between.

  • Iterate from 1 to N to print each row

  • For each row, print N-i spaces followed by 2*i-1 stars

  • Use nested loops to handle spaces and stars accordingly

Add your answer
right arrow

Q14. What is the difference between Method and Function in programming language?

Ans.

Method and Function are both blocks of code that perform a specific task, but the main difference is that a method is associated with an object while a function is not.

  • A method is called on an object, while a function is called independently.

  • A method can modify the state of an object, while a function cannot.

  • A method is defined within a class, while a function is defined outside of a class.

  • Example of a method: object.methodName()

  • Example of a function: functionName()

View 1 answer
right arrow

Q15. How flexibility can help, what are its advantages and disadvantages

Ans.

Flexibility can bring advantages like adaptability and creativity, but can also lead to indecisiveness and lack of focus.

  • Flexibility allows for adaptability to changing situations and creativity in problem-solving.

  • It can also lead to indecisiveness and lack of focus if not balanced with structure and clear goals.

  • Advantages include increased resilience, better teamwork, and improved communication.

  • Disadvantages include potential for burnout and difficulty in prioritizing tasks....read more

Add your answer
right arrow

Q16. Write a program to check whether a string starts with 's' and if it starts with it convert it into an array named anything and print that array one by one.

Ans.

Program to check if a string starts with 's' and convert it to an array

  • Use string method startsWith() to check if the string starts with 's'

  • If it starts with 's', use split() method to convert it into an array

  • Loop through the array and print each element

Add your answer
right arrow

Q17. Swapping of two variables without using temporary variables

Ans.

Swapping two variables without using temporary variables.

  • Use arithmetic operations to swap values

  • X = X + Y

  • Y = X - Y

  • X = X - Y

Add your answer
right arrow

Q18. How to add moving images in flipkart?

Ans.

Moving images can be added in Flipkart by using HTML and CSS animations.

  • Use HTML tag to insert the image

  • Apply CSS animations to create the moving effect

  • Use keyframes to define the animation behavior

Add your answer
right arrow

Q19. Inverse of a number has to be found whose digits difference and sum was given.

Ans.

To find the inverse of a number, calculate the difference and sum of its digits.

  • Iterate through each digit of the number to calculate the sum and difference.

  • Reverse the order of the digits to get the inverse number.

  • For example, if the number is 123, the sum of digits is 1+2+3=6 and the difference is 3-2-1=0. The inverse would be 321.

Add your answer
right arrow

Q20. Logic behind tree and graphs codes?

Ans.

Trees and graphs are used to represent hierarchical and non-linear relationships respectively in data structures and algorithms.

  • Trees are used to represent hierarchical relationships between data points, such as in file systems or organizational structures.

  • Graphs are used to represent non-linear relationships between data points, such as in social networks or transportation systems.

  • Both trees and graphs can be traversed using various algorithms, such as depth-first search or ...read more

Add your answer
right arrow

Q21. Time complexity of nested for loop.

Ans.

Time complexity of nested for loop.

  • The time complexity is O(n^k) where n is the size of the outer loop and k is the size of the inner loop.

  • Nested loops can lead to exponential time complexity.

  • Optimizing the inner loop can improve performance.

Add your answer
right arrow

Q22. What is space complexity?

Ans.

Space complexity refers to the amount of memory used by an algorithm.

  • It is a measure of how much memory an algorithm needs to solve a problem.

  • It is usually expressed in terms of the amount of memory used by the algorithm as a function of the size of the input.

  • Space complexity can be affected by the data structures used in the algorithm.

  • For example, an algorithm that uses a hash table will have a higher space complexity than one that uses a simple array.

Add your answer
right arrow

Q23. Write a program to check whether a given integer is a prime or not and even or odd and it should not give any errors for any kind of inputs.

Ans.

Program to check if an integer is prime, even or odd without errors.

  • Take input integer from user

  • Check if input is valid integer

  • Check if input is prime or not

  • Check if input is even or odd

  • Display the result

Add your answer
right arrow

Q24. What onboarding policies and details were communicated to you?

Ans.

I was informed about the company's onboarding process, including orientation, training, and HR policies.

  • Received an employee handbook outlining company policies and procedures

  • Participated in orientation sessions to learn about company culture and values

  • Completed training on specific job responsibilities and software tools

  • Met with HR to discuss benefits, payroll, and other administrative details

Add your answer
right arrow

Q25. Given an array, write a code to check which number is prime number.

Ans.

Code to check prime numbers in an array

  • Iterate through each number in the array

  • For each number, check if it is divisible by any number from 2 to the square root of the number

  • If the number is only divisible by 1 and itself, it is a prime number

Add your answer
right arrow

Q26. Which programming language you like the most and why?

Ans.

I like Python the most because of its simplicity and versatility.

  • Python has a simple syntax which makes it easy to learn and use.

  • It has a vast library of modules and frameworks for various purposes.

  • Python is used in various fields such as web development, data science, and automation.

  • It supports both object-oriented and functional programming paradigms.

  • Python is also known for its readability and maintainability of code.

  • For example, I have used Python for web scraping, data a...read more

Add your answer
right arrow

Q27. Tell me some technologies that were used in IT industry

Ans.

Technologies used in IT industry include cloud computing, artificial intelligence, blockchain, and internet of things.

  • Cloud computing: AWS, Azure, Google Cloud

  • Artificial intelligence: Machine learning, natural language processing

  • Blockchain: Bitcoin, Ethereum

  • Internet of things: Smart homes, wearables

Add your answer
right arrow

Q28. Difference between a motor and generator?

Ans.

A motor converts electrical energy into mechanical energy, while a generator converts mechanical energy into electrical energy.

  • Motors use electrical energy to create motion, while generators use motion to create electrical energy.

  • Motors have a rotor and a stator, while generators have a stator and a rotor.

  • Examples of motors include electric fans, washing machines, and power tools, while examples of generators include wind turbines and hydroelectric dams.

Add your answer
right arrow

Q29. 1. If this a (showed an obj) and this is b, write a code to add both and get results

Ans.

Code to add two objects and get results

  • Use the + operator to add the values of the objects

  • Ensure that the objects have compatible data types for addition

  • Handle any potential errors or exceptions that may occur during the addition

Add your answer
right arrow

Q30. Difference between sql and sql server?

Ans.

SQL is a language used to manage databases, while SQL Server is a Microsoft product that includes a database management system.

  • SQL is a language used to interact with databases, while SQL Server is a Microsoft product that includes a database management system.

  • SQL can be used with various database management systems like MySQL, Oracle, etc., while SQL Server is specific to Microsoft.

  • SQL is a standard language for querying and managing databases, while SQL Server provides addi...read more

Add your answer
right arrow

Q31. What are the benefits of using python ?

Ans.

Python is a versatile programming language known for its simplicity, readability, and vast library support.

  • Easy to learn and use, making it ideal for beginners and experienced programmers alike

  • Has a large standard library with built-in modules for various tasks, reducing the need for external libraries

  • Supports multiple programming paradigms, including procedural, object-oriented, and functional programming

  • Cross-platform compatibility allows code to run on different operating ...read more

Add your answer
right arrow

Q32. Under 'If' statement if more than 1 statements are there and curly brackets is not there then what will be the output?

Ans.

If more than 1 statements are under 'If' statement without curly brackets, what will be the output?

  • The first statement after 'if' will be executed

  • The second statement will be executed regardless of the condition

  • It can lead to unexpected behavior and bugs

  • Always use curly brackets to avoid confusion

Add your answer
right arrow

Q33. What are star and mesh topology?

Ans.

Star and mesh are network topologies used in computer networking.

  • Star topology connects all devices to a central hub or switch.

  • Mesh topology connects every device to every other device.

  • Star topology is easy to set up and troubleshoot.

  • Mesh topology is highly reliable and fault-tolerant.

  • Examples of star topology include Ethernet and Wi-Fi networks.

  • Examples of mesh topology include sensor networks and peer-to-peer networks.

Add your answer
right arrow

Q34. Explain react in website making?

Ans.

React is a JavaScript library for building user interfaces.

  • React allows developers to create reusable UI components.

  • It uses a virtual DOM for efficient rendering.

  • React can be used to build single-page applications.

  • React is maintained by Facebook and a community of developers.

  • React can be combined with other libraries like Redux for state management.

Add your answer
right arrow

Q35. What is difference between while and Do while

Ans.

While loop checks the condition before executing the code block, while Do while loop executes the code block first and then checks the condition.

  • While loop is entry controlled, Do while loop is exit controlled

  • While loop may not execute at all if the condition is false initially, Do while loop executes at least once

  • Example: while loop - while(i < 5) { //code } vs. do { //code } while(i < 5)

Add your answer
right arrow

Q36. Which Layer in ISO OSI Model handles security

Ans.

The security layer in the ISO OSI Model is the Presentation Layer.

  • The Presentation Layer is responsible for encryption, decryption, and data compression.

  • It ensures that data is securely transmitted between applications.

  • Examples of security protocols at this layer include SSL (Secure Sockets Layer) and TLS (Transport Layer Security).

Add your answer
right arrow

Q37. Tell me some of the features of Java?

Ans.

Java is a popular programming language known for its platform independence and object-oriented features.

  • Java is platform independent, meaning it can run on any platform with a Java Virtual Machine (JVM)

  • Java is object-oriented, allowing for encapsulation, inheritance, and polymorphism

  • Java has automatic memory management through garbage collection

  • Java has a rich set of APIs and libraries for various tasks, such as networking and GUI development

  • Java supports multithreading, allo...read more

View 1 answer
right arrow

Q38. Write the any coding in c language?

Ans.

Here is a simple example of a C program that prints 'Hello, World!'

  • Declare a main function

  • Use the printf function to print 'Hello, World!'

  • Return 0 to indicate successful execution

View 1 answer
right arrow

Q39. What is a latch-up in communications?

Ans.

Latch-up is a phenomenon in which a circuit becomes stuck in a high-current state.

  • It occurs when a parasitic thyristor is inadvertently created within a circuit

  • It can cause permanent damage to the circuit

  • It can be prevented by using proper design techniques and layout

  • Example: A latch-up can occur in a microcontroller when a voltage spike causes the input to exceed the maximum rating

Add your answer
right arrow

Q40. tell me different ways to introduce infinite loop

Ans.

Different ways to introduce infinite loop in programming

  • Using while loop with condition that always evaluates to true

  • Using for loop with condition that never becomes false

  • Using recursion without a base case

  • Using goto statement to jump back to the beginning of the loop

Add your answer
right arrow

Q41. Write a code to print your name

Ans.

Code to print name

  • Use a print statement to output the name

  • Enclose the name in quotes

  • Separate first and last name with a space

View 3 more answers
right arrow

Q42. what are oops and explain them with real time example?

Ans.

OOPs stands for Object-Oriented Programming. It is a programming paradigm based on the concept of objects.

  • OOPs is based on the concept of classes and objects.

  • It focuses on encapsulation, inheritance, and polymorphism.

  • Real-time examples of OOPs include a car, a bank account, and a smartphone.

  • In a car, the engine, wheels, and other components are objects, and the car itself is a class.

  • In a bank account, the account holder's name, account number, and balance are objects, and the...read more

Add your answer
right arrow

Q43. Any questions?

Ans.

Yes, I have a few questions regarding the company culture and team dynamics.

  • Can you tell me more about the team I will be working with?

  • What is the company's approach to professional development?

  • How does the company foster collaboration and communication among teams?

  • What is the company's policy on work-life balance?

Add your answer
right arrow

Q44. what is a circular linked list?

Ans.

A circular linked list is a linked list where the last node points to the first node, forming a loop.

  • Each node has a pointer to the next node and the last node points to the first node

  • Traversal can start from any node and continue until the starting node is reached again

  • Used in applications where data needs to be accessed in a circular manner, such as a playlist

Add your answer
right arrow

Q45. What is an interpreted language

Ans.

An interpreted language is a type of programming language that executes instructions directly, without the need for compilation.

  • Interpreted languages are executed line by line, translating each line into machine code at runtime.

  • Examples of interpreted languages include Python, Ruby, and JavaScript.

  • Interpreted languages are generally slower than compiled languages, as they do not undergo a separate compilation step.

Add your answer
right arrow

Q46. Technological advancements in distributed file systems.

Ans.

Distributed file systems have advanced with features like fault tolerance, scalability, and data consistency.

  • Distributed file systems allow for data to be stored across multiple servers and accessed from anywhere.

  • Advancements include fault tolerance to ensure data availability even if a server fails.

  • Scalability allows for easy expansion as data storage needs grow.

  • Data consistency ensures that all nodes in the system have the same view of the data.

  • Examples of distributed file ...read more

Add your answer
right arrow

Q47. Compile time polymorphism vs runtime polymorphism

Ans.

Compile time polymorphism is method overloading while runtime polymorphism is method overriding.

  • Compile time polymorphism is resolved at compile time while runtime polymorphism is resolved at runtime.

  • Method overloading is an example of compile time polymorphism while method overriding is an example of runtime polymorphism.

  • Compile time polymorphism is faster than runtime polymorphism as it is resolved at compile time.

  • Runtime polymorphism is more flexible than compile time poly...read more

Add your answer
right arrow

Q48. Give some examples where mechanical engineering and IT can work together.

Ans.

Mechanical engineering and IT can work together in various fields.

  • Designing and simulating mechanical systems using computer-aided design (CAD) software

  • Developing and implementing control systems for mechanical devices using programming languages

  • Using sensors and data analysis to optimize mechanical systems

  • Creating virtual reality simulations for training and testing mechanical systems

  • Developing software for 3D printing and additive manufacturing

  • Integrating IT systems with ma...read more

Add your answer
right arrow

Q49. What is Repeater in Communications?

Ans.

A repeater is a device that receives a signal and retransmits it at a higher power or to an extended range.

  • Repeater is used to extend the range of a signal in communication.

  • It receives a signal and amplifies it before retransmitting it.

  • It can be used in radio, television, and telephone communication.

  • Example: Wi-Fi range extenders act as repeaters to boost the signal strength and extend the coverage area.

Add your answer
right arrow

Q50. Difference between Java and c++?

Ans.

Java is a high-level, object-oriented programming language, while C++ is a low-level, general-purpose programming language.

  • Java is platform-independent, while C++ is platform-dependent.

  • Java has automatic memory management (garbage collection), while C++ requires manual memory management.

  • Java supports multithreading and exception handling by default, while C++ requires explicit implementation.

  • Java has a simpler syntax and is easier to learn, while C++ offers more control and p...read more

View 2 more answers
right arrow

Q51. Give the logic of push and pop in stacks?

Ans.

Push adds an element to the top of the stack and pop removes the top element from the stack.

  • Push increases the stack size by 1 and places the new element at the top.

  • Pop removes the top element and decreases the stack size by 1.

  • Stack follows LIFO (Last In First Out) principle.

Add your answer
right arrow

Q52. Call by value and call by reference difference

Ans.

Call by value passes a copy of the value while call by reference passes the memory address of the value.

  • Call by value passes a copy of the value to the function while call by reference passes the memory address of the value.

  • In call by value, any changes made to the parameter inside the function do not affect the original value outside the function.

  • In call by reference, any changes made to the parameter inside the function affect the original value outside the function.

  • Call by...read more

Add your answer
right arrow

Q53. what is the difference between knowldge and wisdom

Ans.

Knowledge is information gained through learning, while wisdom is the ability to apply that knowledge in a meaningful way.

  • Knowledge is theoretical, while wisdom is practical.

  • Knowledge is acquired through education and experience, while wisdom is gained through reflection and introspection.

  • Knowledge is objective, while wisdom is subjective.

  • Examples: Knowing how to drive a car is knowledge, but knowing when to drive and when not to drive is wisdom. Knowing the facts about a dis...read more

Add your answer
right arrow

Q54. How to perform type casting in Java

Ans.

Type casting in Java is the process of converting one data type into another.

  • Use the syntax (newType) variableName to perform type casting.

  • Type casting can be done implicitly or explicitly.

  • Explicit type casting is done by the programmer and may result in data loss if the new type cannot hold the original value.

Add your answer
right arrow

Q55. What about python language?

Ans.

Python is a high-level programming language known for its simplicity and readability.

  • Python is widely used for web development, data analysis, artificial intelligence, and scientific computing.

  • It has a large standard library and supports multiple programming paradigms.

  • Python code is easy to read and maintain, making it a popular choice for beginners and experienced programmers alike.

Add your answer
right arrow

Q56. Swapping of two numbers using temp variable

Ans.

Swapping two numbers using a temporary variable in programming.

  • Declare three variables: a, b, temp.

  • Assign values to a and b.

  • Store the value of a in temp.

  • Assign the value of b to a.

  • Assign the value of temp to b.

  • Now a and b have been swapped.

Add your answer
right arrow

Q57. what do you mean by tcp/ip?

Ans.

TCP/IP stands for Transmission Control Protocol/Internet Protocol. It is a set of protocols that allows computers to communicate over the internet.

  • TCP/IP is a suite of communication protocols used for transmitting data over networks.

  • It provides reliable, connection-oriented communication between devices.

  • TCP is responsible for breaking data into packets, ensuring they are delivered in order and error-free.

  • IP handles the addressing and routing of packets across the internet.

  • Exa...read more

Add your answer
right arrow

Q58. A train travelling at a speed of 75 mph enters a tunnel 31/2 miles long. The train is 1/4 mile long. How long does it take for the train to pass through the tunnel from the moment the front enters to the moment...

read more
Ans.

Calculate the time taken by a train to pass through a tunnel given its speed, length, and the tunnel's length.

  • Convert the speed of the train from mph to miles per minute.

  • Calculate the time taken by the front of the train to enter the tunnel.

  • Calculate the time taken by the rear of the train to exit the tunnel.

  • Subtract the time taken by the front from the time taken by the rear to get the total time taken.

  • Add the units to the final answer.

View 4 more answers
right arrow

Q59. Write a program on inheritance

Ans.

A program demonstrating inheritance in programming

  • Inheritance allows a class to inherit properties and methods from another class

  • The derived class can add its own properties and methods

  • Inheritance promotes code reusability and modularity

  • Example: Creating a base class 'Animal' with properties like 'name' and 'age', and a derived class 'Dog' inheriting from 'Animal' with an additional property 'breed'

View 2 more answers
right arrow

Q60. write a code to swap 2 numbers without using pointer, using function

Ans.

Code to swap 2 numbers without using pointer, using function

  • Create a function that takes two integer parameters

  • Inside the function, swap the values of the parameters using a temporary variable

  • Return the swapped values

  • Call the function and pass the two numbers to be swapped as arguments

Add your answer
right arrow

Q61. 4 pillars of object oriented programming

Ans.

The 4 pillars of OOP are Abstraction, Encapsulation, Inheritance, and Polymorphism.

  • Abstraction: Hiding implementation details and showing only necessary information.

  • Encapsulation: Binding data and functions together to protect data from outside interference.

  • Inheritance: Creating new classes from existing ones, inheriting properties and methods.

  • Polymorphism: Using a single interface to represent multiple types of objects.

Add your answer
right arrow

Q62. Explain normalisation and types

Ans.

Normalization is the process of organizing data in a database to eliminate redundancy and improve data integrity.

  • Normalization is used to minimize data duplication and ensure consistency.

  • There are different normal forms (1NF, 2NF, 3NF, etc.) that define specific rules for organizing data.

  • Normalization helps in reducing data anomalies and improving database performance.

  • Normalization involves breaking down a large table into smaller, more manageable tables.

  • Each normal form has ...read more

Add your answer
right arrow

Q63. What is inheritance in Java?

Ans.

Inheritance is a mechanism in Java where a class acquires the properties and methods of another class.

  • It allows for code reusability and promotes a hierarchical structure of classes.

  • The subclass inherits all the non-private members (fields, methods) of the superclass.

  • The keyword 'extends' is used to create a subclass.

  • Example: class Dog extends Animal { ... }

  • Multiple inheritance is not allowed in Java.

Add your answer
right arrow

Q64. When and how to use functions?

Ans.

Functions are used to break down complex tasks into smaller, reusable parts.

  • Functions should be used when a task needs to be performed multiple times in a program.

  • Functions make code more organized and easier to read.

  • Functions can take parameters and return values to make them more versatile.

  • Functions can be used to break down complex tasks into smaller, more manageable parts.

  • Functions can be used to improve code reusability and reduce redundancy.

Add your answer
right arrow

Q65. How to use static in class?

Ans.

Static keyword is used to create class-level variables and methods that can be accessed without creating an instance of the class.

  • Static variables and methods are declared using the keyword 'static'

  • Static variables are shared among all instances of the class

  • Static methods can be called without creating an instance of the class

  • Static methods cannot access non-static variables or methods

  • Example: public static int count = 0; // static variable

  • Example: public static void printCou...read more

Add your answer
right arrow

Q66. two puzzles: 1. how can you cut a cake in 8 pieces in minimum number of cuts(answered) ,2.make 4 equilateral triangles using 6 matchsticks(answered)

Ans.

1. Cut cake in 8 pieces in minimum cuts. 2. Make 4 equilateral triangles using 6 matchsticks.

  • 1. Cut cake in half horizontally and vertically. Cut each quarter diagonally.

  • 2. Use 3 matchsticks to form a triangle. Use the other 3 to connect the centers of each triangle.

  • Both puzzles require creative thinking and problem-solving skills.

View 3 more answers
right arrow

Q67. What is an Integrated Circuit?

Ans.

An Integrated Circuit is a miniaturized electronic circuit consisting of interconnected semiconductor devices.

  • ICs are used in almost all electronic devices

  • They can be analog, digital or mixed-signal

  • ICs can be classified as SSI, MSI, LSI or VLSI based on the number of transistors they contain

  • Examples of ICs include microprocessors, memory chips, and amplifiers

Add your answer
right arrow

Q68. What are key constraints ?

Ans.

Key constraints are rules that enforce uniqueness and relationships in a database.

  • Key constraints ensure that each record in a table is uniquely identified.

  • Primary key constraint enforces uniqueness and ensures each record has a unique identifier.

  • Foreign key constraint establishes a relationship between two tables based on a key field.

  • Unique key constraint ensures that all values in a column are unique.

Add your answer
right arrow

Q69. Explain SQL join statements

Ans.

SQL join statements are used to combine rows from two or more tables based on a related column between them.

  • Join statements are used to retrieve data from multiple tables in a single query.

  • Common types of join statements include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.

  • Join conditions are specified using the ON keyword followed by the columns to join on.

  • Join statements can be used to fetch related data from different tables based on a common column.

  • Example: SELECT * F...read more

Add your answer
right arrow

Q70. OOP oriented in the case of C++

Ans.

C++ supports Object-Oriented Programming (OOP) through classes and objects.

  • C++ allows for the creation of classes, which are user-defined data types that can have member functions and variables.

  • Objects are instances of classes, allowing for data encapsulation and abstraction.

  • Inheritance, polymorphism, and encapsulation are key principles of OOP supported by C++.

Add your answer
right arrow

Q71. Programming code for Fibonacci series

Ans.

Fibonacci series is a sequence of numbers where each number is the sum of the two preceding ones.

  • Start with two variables, a and b, initialized to 0 and 1 respectively

  • Loop through the desired number of iterations and calculate the next number in the sequence by adding a and b

  • Assign the value of b to a and the value of the new number to b

  • Repeat until desired number of iterations is reached

Add your answer
right arrow

Q72. What are cypher technique and explain cypher

Ans.

Cypher is a cryptographic technique used to encrypt and decrypt data.

  • Cypher is a method of encoding information to keep it secure from unauthorized access.

  • It involves using algorithms to transform plaintext into ciphertext, and vice versa.

  • Examples of cypher techniques include AES, DES, and RSA.

Add your answer
right arrow

Q73. What is object oriented programming language

Ans.

Object oriented programming language is a type of programming language that uses objects and classes to organize code.

  • Uses objects and classes to model real-world entities

  • Encapsulates data and behavior within objects

  • Supports inheritance, polymorphism, and encapsulation

  • Examples include Java, C++, Python

Add your answer
right arrow

Q74. Projects done, write a code whether a number is odd or even

Ans.

Code to check if a number is odd or even

  • Use the modulo operator (%) to check if the remainder is 0 or 1

  • If remainder is 0, number is even. If remainder is 1, number is odd

  • Example: int num = 5; if(num % 2 == 0) { //even number } else { //odd number }

Add your answer
right arrow

Q75. Write a c program reversing your name

Ans.

A C program to reverse a given name.

  • Declare a character array to store the name.

  • Use scanf() to take input of the name.

  • Use strlen() function to find the length of the name.

  • Use a for loop to iterate through the name in reverse order.

  • Print the reversed name using printf().

Add your answer
right arrow

Q76. Difference between DBMS and RDBMS

Ans.

DBMS is a software system to manage databases while RDBMS is a type of DBMS that stores data in tables with relations.

  • DBMS stands for Database Management System while RDBMS stands for Relational Database Management System.

  • DBMS can manage any type of database while RDBMS manages only relational databases.

  • DBMS does not enforce any specific data model while RDBMS enforces the relational data model.

  • Examples of DBMS include MongoDB, Cassandra, and Redis while examples of RDBMS inc...read more

Add your answer
right arrow

Q77. OOPs concepts explanation with examples

Ans.

OOPs concepts are fundamental principles in object-oriented programming that help in organizing code efficiently.

  • Encapsulation: Bundling data and methods that operate on the data into a single unit (class). Example: Class Car with properties like make, model, and methods like start(), stop().

  • Inheritance: Ability of a class to inherit properties and behavior from another class. Example: Class SUV inheriting from Class Car.

  • Polymorphism: Ability to present the same interface for...read more

Add your answer
right arrow

Q78. 1. What is polymorphism

Ans.

Polymorphism is the ability of a function or method to behave differently based on the object it is acting upon.

  • Polymorphism allows objects of different classes to be treated as objects of a common superclass.

  • There are two types of polymorphism: compile-time (method overloading) and runtime (method overriding).

  • Example: Inheritance in OOP allows a child class to override a method from its parent class, exhibiting polymorphic behavior.

Add your answer
right arrow

Q79. What is String? What is DBMS?

Ans.

String is a sequence of characters. DBMS is a software system that manages databases.

  • String is a data type used to represent text in programming languages.

  • DBMS stands for Database Management System.

  • String example: 'Hello, World!'

  • DBMS example: MySQL, Oracle, SQL Server

Add your answer
right arrow

Q80. What is python?

Ans.

Python is a high-level programming language known for its simplicity and readability.

  • Python is interpreted, not compiled

  • It supports multiple programming paradigms like procedural, object-oriented, and functional programming

  • Python has a large standard library and a vibrant community for support

  • Example: print('Hello, World!') is a simple Python program that prints 'Hello, World!' to the console

Add your answer
right arrow

Q81. What is Captcha?

Ans.

Captcha is a security measure used to determine whether a user is human or a bot by presenting a challenge that is easy for humans to solve but difficult for bots.

  • Captcha stands for Completely Automated Public Turing test to tell Computers and Humans Apart.

  • It typically involves distorted text that the user must enter correctly to proceed.

  • Captcha can also include image recognition tasks or simple puzzles.

  • Captcha helps prevent automated bots from accessing websites or submittin...read more

Add your answer
right arrow

Q82. What are iterations?

Ans.

Iterations are repetitive processes in programming that allow for the execution of a block of code multiple times.

  • Iterations are used to perform a task repeatedly until a certain condition is met.

  • They are commonly used in loops such as for, while, and do-while loops.

  • Iterations can also be used to iterate over data structures such as arrays and lists.

  • Examples of iterations include printing numbers from 1 to 10, summing the elements of an array, and searching for a specific val...read more

Add your answer
right arrow

Q83. what do you know about cts?

Ans.

CTS is a multinational IT services company headquartered in India.

  • CTS stands for Cognizant Technology Solutions.

  • It provides services in areas like digital, technology, consulting, and operations.

  • It has a global presence with offices in over 40 countries.

  • CTS is one of the largest IT services companies in the world.

  • It has been ranked among the top companies for employee satisfaction and diversity.

Add your answer
right arrow

Q84. What is JVM,JDK,Abstraction?

Ans.

JVM is a virtual machine that executes Java bytecode. JDK is a software development kit for Java. Abstraction is a concept of hiding implementation details.

  • JVM stands for Java Virtual Machine and is responsible for executing Java bytecode.

  • JDK stands for Java Development Kit and is a software development kit for Java.

  • Abstraction is a concept of hiding implementation details and exposing only necessary information.

  • Abstraction is achieved through interfaces and abstract classes ...read more

Add your answer
right arrow

Q85. C program for even and odd

Ans.

A C program to determine if a number is even or odd.

  • Use the modulo operator to check if the number is divisible by 2.

  • If the remainder is 0, the number is even. Otherwise, it is odd.

  • Print the result to the console or store it in a variable for later use.

Add your answer
right arrow

Q86. What Is the probability of it raining today in Chennai?

Ans.

The probability of rain in Chennai today depends on various factors such as season, weather conditions, and location.

  • The probability can be estimated by analyzing the current weather patterns and historical data.

  • Factors such as humidity, temperature, and wind speed can affect the probability of rain.

  • Local weather forecasts and satellite imagery can also provide insights into the likelihood of rain.

  • The probability of rain can range from 0% to 100%, with higher probabilities in...read more

Add your answer
right arrow

Q87. What are lists? What are data structures?

Ans.

Lists are a collection of ordered elements. Data structures are ways of organizing and storing data.

  • Lists are used to store and manipulate data in a specific order.

  • Data structures are used to organize and store data in a way that makes it easy to access and manipulate.

  • Examples of data structures include arrays, stacks, queues, and trees.

Add your answer
right arrow

Q88. Define OOPS concepts

Ans.

OOPS concepts are fundamental principles in object-oriented programming that help in designing and implementing software solutions.

  • Encapsulation: Bundling data and methods together in a class to hide implementation details.

  • Inheritance: Creating new classes by inheriting properties and behaviors from existing classes.

  • Polymorphism: Ability of objects to take on many forms and perform different actions based on the context.

  • Abstraction: Simplifying complex systems by breaking the...read more

Add your answer
right arrow

Q89. What are different types of loops in c

Ans.

There are three types of loops in C: for, while, and do-while.

  • For loop is used when the number of iterations is known beforehand.

  • While loop is used when the number of iterations is not known beforehand.

  • Do-while loop is similar to while loop, but it executes the code block at least once before checking the condition.

Add your answer
right arrow

Q90. What is Type casting

Ans.

Type casting is the process of converting a variable from one data type to another.

  • Type casting can be implicit or explicit.

  • Implicit type casting is done automatically by the compiler.

  • Explicit type casting requires the programmer to specify the conversion.

  • Example: converting an integer to a float in order to perform division with decimal precision.

Add your answer
right arrow

Q91. Swapping of two numbers

Ans.

Swapping two numbers involves exchanging the values of two variables.

  • Create a temporary variable to store one of the numbers

  • Assign the value of the first number to the second number

  • Assign the value of the temporary variable to the first number

Add your answer
right arrow

Q92. Write a code to explain method overriding.

Ans.

Method overriding is when a subclass provides a specific implementation of a method that is already provided by its parent class.

  • In method overriding, the method in the subclass has the same name, return type, and parameters as the method in the parent class.

  • The overridden method in the subclass should have the same or broader access modifier than the method in the parent class.

  • Example: class Animal { void sound() { System.out.println('Animal sound'); } } class Dog extends An...read more

Add your answer
right arrow

Q93. say ABT PROJECT any software skills acquired

Ans.

I have acquired software skills in Java, SQL, and Python through various projects.

  • Proficient in Java programming language

  • Experience with SQL databases

  • Familiar with Python scripting

Add your answer
right arrow

Q94. Write a basic if-else condition code.

Ans.

If-else condition code example

  • Use if keyword followed by a condition in parentheses

  • Use curly braces to enclose the code to be executed if the condition is true

  • Use else keyword followed by curly braces to enclose the code to be executed if the condition is false

  • The else block is optional

  • Example: if(age > 18) { System.out.println('You are an adult'); } else { System.out.println('You are a minor'); }

Add your answer
right arrow

Q95. 5.Write any program in c language

Ans.

Program to print 'Hello, World!' in C language

  • Include stdio.h header file

  • Use printf() function to print the message

  • End the program with return 0 statement

Add your answer
right arrow

Q96. Find the probability that India will win the next Cricket World Cup

Ans.

It is impossible to accurately predict the probability of India winning the next Cricket World Cup.

  • Sports events are unpredictable and depend on various factors such as team performance, weather conditions, injuries, etc.

  • Past performance of the team and individual players can be considered, but it does not guarantee future success.

  • Other teams participating in the tournament also play a significant role in determining the probability of India winning.

  • Therefore, it is not possi...read more

Add your answer
right arrow

Q97. Sort the array in increasing order.

Ans.

To sort an array in increasing order, we can use any sorting algorithm like bubble sort, insertion sort, or quicksort.

  • Choose a sorting algorithm based on the size of the array and the time complexity required.

  • Implement the chosen algorithm in the programming language of choice.

  • Test the sorting function with different input arrays to ensure correctness.

Add your answer
right arrow

Q98. Write a query to find the employee name who earns maximum salary

Ans.

The query finds the employee name who earns the maximum salary.

  • Use the SELECT statement to retrieve the employee name and salary from the database table.

  • Use the ORDER BY clause to sort the results in descending order based on salary.

  • Use the LIMIT clause to limit the result to only one row.

  • Return the employee name from the query result.

View 2 more answers
right arrow

Q99. What are the types of the dashboards you have worked in Tableau?

Ans.

I have worked on various types of dashboards in Tableau including interactive dashboards, performance dashboards, and executive dashboards.

  • Interactive dashboards

  • Performance dashboards

  • Executive dashboards

Add your answer
right arrow

Q100. What is the ETL tool used for Data wrangling and what is your proficiency on the same?

Ans.

The ETL tool used for Data wrangling is Apache Spark. I have a high proficiency in using Apache Spark for ETL processes.

  • Apache Spark is a powerful open-source distributed computing system that can handle large-scale data processing and analytics.

  • It provides a unified engine for big data processing with built-in modules for SQL, streaming, machine learning, and graph processing.

  • I have experience in using Apache Spark for data wrangling tasks such as data cleaning, transformati...read more

Add your answer
right arrow
1
2
3
4
5
6
Next

More about working at Cognizant

Back
Awards Leaf
AmbitionBox Logo
Top Rated Mega Company - 2024
Awards Leaf
Awards Leaf
AmbitionBox Logo
Top Rated IT/ITES Company - 2024
Awards Leaf
HQ - Teaneck. New Jersey., United States (USA)
Contribute & help others!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos

Interview Process at Cognizant for Freshers

based on 375 interviews
Interview experience
4.2
Good
View more
interview tips and stories logo
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Interview Questions from Similar Companies

Paytm Logo
3.3
 • 458 Interview Questions
EPAM Systems Logo
3.7
 • 395 Interview Questions
Startek Logo
3.1
 • 173 Interview Questions
Lenskart Logo
3.2
 • 165 Interview Questions
Adani Power Logo
3.9
 • 139 Interview Questions
View all
Recently Viewed
INTERVIEWS
HDFC Life
Fresher
20 top interview questions
SALARIES
HDFC Life
LIST OF COMPANIES
Yes Bank
Locations
SALARIES
HDFC Life
SALARIES
HDFC Life
INTERVIEWS
Bajaj Allianz Life Insurance
No Interviews
SALARIES
Bajaj Allianz Life Insurance
INTERVIEWS
Yes Bank
Fresher
20 top interview questions
SALARIES
SBI Life Insurance Company
SALARIES
Bajaj Allianz Life Insurance
Top Cognizant Interview Questions And Answers
Share an Interview
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
75 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter