
Cognizant


3000+ Cognizant Interview Questions and Answers
Q1. 1 Tell me about your self 2 What is c# 3 What is oops concept 4 What is Delegate 5 Difference between polymorphism and what are its type 6 What is out and ref keyword 7 What is call by ref and call by value 8 W...
read moreInterview questions for Programmer Analyst position
C# is a programming language used for developing Windows applications
OOPS concepts include inheritance, encapsulation, abstraction, and polymorphism
Delegate is a type that represents references to methods with a specific parameter list and return type
Polymorphism is the ability of an object to take on many forms. Types include compile-time and runtime polymorphism
Out and ref keywords are used for passing arguments by referenc...read more
Q2. 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
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
Q3. Nth Fibonacci Number Problem Statement
Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2)
, with initial conditions F(1) = F(2) = 1
.
Input:
The inp...read more
Calculate the Nth Fibonacci number efficiently using dynamic programming.
Use dynamic programming to store and reuse previously calculated Fibonacci numbers.
Start with base cases F(1) and F(2) as 1, then calculate subsequent Fibonacci numbers.
Optimize the solution to avoid redundant calculations by storing intermediate results.
Time complexity can be reduced to O(N) using dynamic programming.
Example: For N = 5, the 5th Fibonacci number is 5.
Q4. What is meant by quality and brief explanation of it with an example?
Quality refers to the degree of excellence or superiority of a product or service.
Quality is subjective and can vary depending on the customer's expectations.
It can be measured through various metrics such as defect rate, customer satisfaction, and reliability.
For example, a high-quality car would have a low defect rate, high customer satisfaction, and be reliable.
Quality is important for customer loyalty and brand reputation.
Continuous improvement is necessary to maintain an...read more
Q5. Pair Sum Problem Statement
You are given an integer array 'ARR' of size 'N' and an integer 'S'. Your task is to find and return a list of all pairs of elements where each sum of a pair equals 'S'.
Note:
Each pa...read more
Find pairs of elements in an array that sum up to a given value, sorted in a specific order.
Iterate through the array and for each element, check if the complement (S - current element) exists in a hash set.
Keep track of pairs in a hash set to avoid duplicates.
Sort the pairs based on the criteria mentioned in the problem statement.
Return the sorted list of pairs.
Q6. 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 moreCalculate 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.
Q7. Alien Dictionary Problem Statement
You are provided with a sorted dictionary (by lexical order) in an alien language. Your task is to determine the character order of the alien language from this dictionary. Th...read more
Given a sorted alien dictionary in an array of strings, determine the character order of the alien language.
Iterate through the words in the dictionary to build a graph of character dependencies.
Perform a topological sort on the graph to determine the character order.
Return the character array representing the order of characters in the alien language.
Q8. Buy and Sell Stock - III Problem Statement
Given an array prices
where the ith element represents the price of a stock on the ith day, your task is to determine the maximum profit that can be achieved at the en...read more
Determine the maximum profit that can be achieved by selling stocks with at most two transactions.
Iterate through the array and calculate the maximum profit that can be achieved by selling at each day.
Keep track of the maximum profit that can be achieved after the first transaction and the maximum profit that can be achieved after the second transaction.
Return the maximum profit that can be achieved after the second transaction.
Q9. What is stack? How do you convert a queue to stack?
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
Q10. 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 ?
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
Q11. What array list and linkedlist difference,how hashmap internally working,what is synchronised and it's type,what is difference between abstract and interface,class loading mechanism in Java, you hat is single t...
read moreJava Developer interview questions covering array list, linkedlist, hashmap, synchronization, abstract vs interface, singleton class, Spring framework, database configuration, and Java 8 features.
ArrayList and LinkedList differ in terms of implementation, performance, and usage
HashMap uses hashing to store and retrieve key-value pairs
Synchronized is used to ensure thread safety and prevent race conditions
Abstract classes cannot be instantiated and can have both abstract and n...read more
Q12. Tell me the logic of program to reverse a given string word by word without using any built in function.
The logic of the program is to reverse a given string word by word without using any built-in function.
Split the string into an array of words using whitespace as the delimiter.
Iterate through the array of words in reverse order.
Append each word to a new string, separated by a space.
Q13. What do you mean by BPO and what do you understand by the term of insurance
BPO stands for Business Process Outsourcing. Insurance refers to a contract between an individual and an insurance company.
BPO involves outsourcing non-core business functions to a third-party provider
Insurance is a means of protection against financial loss
Types of insurance include life, health, auto, and property insurance
Insurance companies collect premiums from policyholders and use the funds to pay out claims
BPO services can be used in the insurance industry for tasks s...read more
Q14. What’s breach? What happens if either party breaches a contract?
Breach is a violation of a contract. It can result in legal action and damages.
Breach occurs when one party fails to fulfill their obligations under a contract.
It can be a material breach, which is a serious violation, or a minor breach.
If a breach occurs, the non-breaching party can seek legal action and damages.
For example, if a contractor fails to complete a project on time, the client may sue for damages.
If an employee breaches a non-compete agreement, the employer may se...read more
Q15. 2.What programming language are you proficient with..?
I am proficient in multiple programming languages including Java, Python, and C++.
Proficient in Java, Python, and C++
Experience with web development languages such as HTML, CSS, and JavaScript
Familiarity with scripting languages like Bash and PowerShell
Knowledge of database languages like SQL and NoSQL
Comfortable with object-oriented programming and design patterns
Q16. What is the function of spark plug in diesel engine?
Spark plug ignites the fuel-air mixture in diesel engine to start combustion process.
Spark plug creates a spark to ignite the fuel-air mixture in the combustion chamber
This starts the combustion process which powers the engine
Diesel engines usually have glow plugs to preheat the combustion chamber for easier ignition
Q17. How to decide whether to use "call" or "apply" in javascript?
The choice between 'call' and 'apply' in JavaScript depends on whether you have the arguments as an array or as individual parameters.
Use 'call' when you have the arguments as individual parameters.
Use 'apply' when you have the arguments as an array.
Both 'call' and 'apply' allow you to invoke a function with a specific 'this' value.
Q18. Minimum Steps for a Knight to Reach Target
Given a square chessboard of size 'N x N', determine the minimum number of moves a Knight requires to reach a specified target position from its initial position.
Expl...read more
Calculate minimum steps for a Knight to reach target position on a chessboard.
Use BFS algorithm to find shortest path from Knight's starting position to target position.
Consider all possible moves of the Knight on the chessboard.
Keep track of visited positions to avoid revisiting them.
Return the minimum number of moves required for the Knight to reach the target position.
Q19. Application of Row_Number, Rank, and Dense Rank? Different stages of defects/Bugs? What are Schema objects? Different types of loads in ETL Testing? What is Junk Dimension? SQL to remove duplicates from a table...
read moreInterview questions on SQL and ETL testing
Row_Number, Rank, and Dense Rank are used for ranking and ordering data in SQL
Defects/Bugs can be classified into different stages such as Open, In Progress, Resolved, Closed, etc.
Schema objects are database objects such as tables, views, indexes, etc.
Different types of loads in ETL Testing include Full Load, Incremental Load, and Delta Load
Junk Dimension is a dimension table that contains low cardinality columns
SQL to remove duplicat...read more
Q20. Minimize Hamming Distance Problem
Ninja has strategically formed a team to combat enemies in his city. Each ninja in the team has a specific range of attack, and the team has successfully acquired the attack ra...read more
Minimize Hamming distance between two arrays by swapping elements at allowed indices.
Iterate through allowed swaps and swap elements in ninja array accordingly.
Calculate Hamming distance between ninja and enemies arrays after swaps.
Return the minimum Hamming distance obtained.
Q21. What is an API? Why APIs are so popular these days? What is API Management? Why we need an API Management tool such as Apigee Edge? What is REST? What is the difference between SOAP & REST API ? What is API Pro...
read moreAnswers to common questions related to APIs, API management, and Apigee Edge
API stands for Application Programming Interface and is a set of protocols and tools for building software applications
APIs are popular because they allow different software systems to communicate and share data with each other
API management involves the process of creating, publishing, documenting, and analyzing APIs
Apigee Edge is an API management tool that provides features such as security, analyt...read more
Q22. If we have 200 staging tables, 40 dimensions tables and 20 facts table, How will you compare it with target systems
The number of staging, dimension and fact tables in source and target systems need to be compared.
Compare the number of staging, dimension and fact tables in source and target systems.
Check if the table names and column names are consistent in both systems.
Verify if the data types and data values are matching in both systems.
Ensure that the ETL process is properly mapping the data from source to target systems.
Perform data profiling to identify any discrepancies between the s...read more
Q23. 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)
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.
Q24. What are OOP characteristics? Difference between abstraction and encapsulation? What are types of polymorphism ?4 to 5 Question on projects which I have mentioned in cv. Write a program to find the prime factor...
read moreAnswering questions related to OOP characteristics, polymorphism, and programming projects.
OOP characteristics include inheritance, encapsulation, abstraction, and polymorphism.
Abstraction is the process of hiding implementation details while encapsulation is the process of hiding data.
Types of polymorphism include compile-time and runtime polymorphism.
Projects mentioned in CV were discussed and explained.
A program to find prime factors of a number can be written using a loop...read more
Q25. Maximum Difference Problem Statement
Given an array ARR
of N
elements, your task is to find the maximum difference between any two elements in ARR
.
If the maximum difference is even, print EVEN; if it is odd, p...read more
Find the maximum difference between any two elements in an array and determine if it is even or odd.
Iterate through the array to find the maximum and minimum elements
Calculate the difference between the maximum and minimum elements
Check if the difference is even or odd and return the result
Q26. Next Greater Element Problem Statement
Given a list of integers of size N
, your task is to determine the Next Greater Element (NGE) for every element. The Next Greater Element for an element X
is the first elem...read more
The task is to find the next greater element for each element in a list of integers.
Iterate through the list of integers from right to left.
Use a stack to keep track of elements whose next greater element is yet to be found.
Pop elements from the stack until a greater element is found or the stack is empty.
Assign the next greater element to the current element or -1 if no greater element is found.
Return the list of next greater elements.
Q27. Why is java platform independent?
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.
Q28. Minimum Stops for Ninja's Journey Problem Statement
Ninja wishes to travel from his house to a destination X
miles away. He knows there are Y
gas stations along the way, each station i
located at a distance d[i...read more
Calculate the minimum number of refueling stops needed for a ninja to reach a destination with given gas stations and starting fuel.
Iterate through gas stations while maintaining current fuel level and number of stops made
Refuel at each station if necessary to ensure enough fuel to reach the next station or destination
Keep track of the minimum number of stops needed to reach the destination
Q29. Pairwise Sum of Hamming Distance
Given an array ARR
containing N
integers, your task is to calculate the total sum of the Hamming Distance for all possible pairs of elements in the array.
Hamming Distance
The H...read more
Calculate the total sum of Hamming Distance for all possible pairs of elements in an array.
Iterate through all pairs of elements in the array
Calculate the Hamming Distance between each pair of elements
Sum up all the calculated Hamming Distances
Q30. Star Pattern Problem Explanation
Given a non-negative integer 'N', print a star pattern according to the specified format.
Input:
N (Total no. of rows)
Output:
Pattern in N lines
Example:
Consider N = 4, the pa...read more
Print a star pattern based on the given non-negative integer 'N'.
Iterate from 1 to N and print '*' in each row with increasing count
Use nested loops to print spaces before the '*' in each row
Ensure to print the correct number of spaces before the '*' in each row
Handle the edge case where N is 0 separately
Q31. WHAT YOU KNOW HEALTH CARE DOMAIN IN THE US SYSTEM?
I have knowledge of the US healthcare system and its regulations.
I am aware of the Affordable Care Act (ACA) and its impact on the healthcare industry.
I understand the role of insurance companies and government programs like Medicare and Medicaid.
I know about the various healthcare providers such as hospitals, clinics, and private practices.
I am familiar with the electronic health record (EHR) system and its importance in healthcare.
I have knowledge of healthcare data managem...read more
Q32. Merge Intervals Problem Statement
You are provided with 'N' intervals, each containing two integers denoting the start time and end time of the interval.
Your task is to merge all overlapping intervals and retu...read more
Merge overlapping intervals and return sorted list of merged intervals by start time.
Iterate through intervals and merge overlapping ones
Sort merged intervals by start time
Return the sorted list of merged intervals
Q33. DFS Traversal Problem Statement
Given an undirected and disconnected graph G(V, E)
, where V
is the number of vertices and E
is the number of edges, the connections between vertices are provided in the 'GRAPH' m...read more
DFS traversal problem on an undirected and disconnected graph to find connected components.
Use Depth First Search (DFS) algorithm to traverse the graph and find connected components.
Maintain a visited array to keep track of visited vertices.
For each unvisited vertex, perform DFS to explore all connected vertices and form a connected component.
Repeat the process until all vertices are visited and print the connected components.
Handle disconnected components by starting DFS fro...read more
Q34. What is the difference between structure and class?
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; }
Q35. 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 moreAnswering 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.
Q36. A frog is stuck in a 100m deep well. the jump takes it 2 m high but he falls down 1m as well. It continues doing until it reaches the top of well. so how many jumps will be required by frog to get out of the we...
read moreThe frog will require 98 jumps to get out of the well.
The frog jumps 2m high but falls down 1m, so it covers a net distance of 1m with each jump.
To calculate the number of jumps, we need to subtract the initial jump of 2m from the total depth of the well (100m).
The remaining distance to cover is 100m - 2m = 98m.
Since the frog covers 1m with each jump, it will require 98 jumps to cover the remaining distance and reach the top of the well.
Q37. How to get the count of all text box in a web page?
Use Selenium WebDriver to find and count all text boxes on a web page.
Use Selenium WebDriver to locate all text boxes on the web page
Use findElements method with input tag and type attribute as text to find all text boxes
Get the size of the list of elements to get the count of text boxes
Q38. 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?
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.
Q39. are you aware by the formulas used in excel
Yes, I am aware of the formulas used in Excel.
I am familiar with basic formulas such as SUM, AVERAGE, MAX, MIN, etc.
I also know how to use more complex formulas such as VLOOKUP, IF statements, and nested functions.
I am comfortable with creating and using named ranges, and using functions with cell references.
I am also familiar with using Excel's built-in functions for statistical analysis and financial calculations.
Overall, I am confident in my ability to use Excel to perform...read more
Q40. 1. Type of documentation for computer system validation. 2.Please explain recent or current one software execution and computer sytem validation. 3. What is Security policy for GxP computerization system? 4.wha...
read moreTechnical Lead interview questions on computer system validation, documentation, security policy, data integrity, GAMP5, risk assessment, backup and restoration, software categories, and more.
Types of documentation for computer system validation
Recent/current software execution and computer system validation
Security policy for GxP computerization system
Traceability matrix and its purpose
ALCOA and ALCOA+ principles
Definition and importance of data integrity
Regulatory points fo...read more
Q41. Reverse the String Problem Statement
You are given a string STR
which contains alphabets, numbers, and special characters. Your task is to reverse the string.
Example:
Input:
STR = "abcde"
Output:
"edcba"
Input...read more
Reverse a given string containing alphabets, numbers, and special characters.
Iterate through the string from the end to the beginning and append each character to a new string.
Use built-in functions like reverse() or slicing to reverse the string.
Handle special characters and numbers while reversing the string.
Ensure to consider the constraints provided in the problem statement.
Q42. What is the difference between RDBMS and DBMS? Explain database with a real life example of database.
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
Q43. Write a code of Prime number which are printed in the Right angle triangle format.
Code to print prime numbers in right angle triangle format.
Create a function to check if a number is prime or not.
Use nested loops to print the numbers in right angle triangle format.
Start with the first prime number and keep adding prime numbers to the triangle.
Example: 2 3 5 7 11 13 17 19 23 29
Q44. What are different type of data structures and explain any 2 of them?
Data structures are ways to organize and store data. Two examples are arrays and linked lists.
Arrays are a collection of elements of the same data type, stored in contiguous memory locations.
Linked lists are a collection of nodes, each containing data and a reference to the next node in the list.
Q45. 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.
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.
Q46. Ways To Make Coin Change
Given an infinite supply of coins of varying denominations, determine the total number of ways to make change for a specified value using these coins. If it's not possible to make the c...read more
The task is to find the total number of ways to make change for a specified value using given denominations.
Create a dynamic programming table to store the number of ways to make change for each value up to the target value.
Iterate through each denomination and update the table accordingly.
The final answer will be the value in the table at the target value.
Consider edge cases like when the target value is 0 or when there are no denominations that can make the change.
Example: ...read more
Q47. 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
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
Q48. 1. Project description 2. Technologies used in recent project 3. What is dependency injection 4. Difference between Rest and Soap 5. Difference between Monolithic and Microservice 6. Features of Java 8 7. Progr...
read moreInterview questions for Software Engineer position
Describe recent project and technologies used
Explain dependency injection and differences between Rest and Soap
Differentiate Monolithic and Microservice architecture
List features of Java 8 and write programs using Java 8
Provide pseudo code for sorting a list of integers without using Java 8 sort method
Define functional interface and its annotation
Q49. Sort Array Problem Statement
Given an array consisting of 'N' positive integers where each integer is either 0, 1, or 2, your task is to sort the given array in non-decreasing order.
Input:
Each input starts wi...read more
Sort an array of positive integers (0, 1, 2) in non-decreasing order.
Iterate through the array and count the occurrences of 0, 1, and 2.
Update the array with the counts of each element in non-decreasing order.
Print the sorted array for each test case.
Q50. Black Friday Discount Challenge
Imagine it's Black Friday and a supermarket is offering a discount to every 'Nth' customer. You are tasked with calculating bills for customers based on product prices and quanti...read more
The challenge involves calculating bills for customers on Black Friday based on discounts for every 'Nth' customer.
Implement 'blackFriday' function to initialize discount for every Nth customer
Implement 'generateBill' function to calculate total bill for each customer's purchase
Consider input constraints and generate final bill amounts for each customer in each test case
Q51. you have a train booking system.what will be the primary feature you will test?
The primary feature to test in a train booking system would be the booking process.
Test the ability to search for available trains and seats
Test the ability to select and reserve seats
Test the payment process
Test the confirmation and ticket generation process
Q52. Number of Islands Problem Statement
You are provided with a 2-dimensional matrix having N
rows and M
columns, containing only 1s (land) and 0s (water). Your goal is to determine the number of islands in this ma...read more
Count the number of islands in a 2D matrix of 1s and 0s.
Use Depth First Search (DFS) or Breadth First Search (BFS) to traverse the matrix and identify connected groups of 1s.
Maintain a visited array to keep track of visited cells to avoid revisiting them.
Increment the island count each time a new island is encountered.
Consider all eight possible directions for connectivity between cells.
Handle edge cases like out of bounds indices and already visited cells.
Q53. What is the difference between Method and Function in programming language?
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()
Q54. write program fibonacci series, write program using boolean, write class cast exceptn, singleton design pattern(like you have to jvm one have jdk 1.7 and other have jdk 1.8 how many instance created if one then...
read moreThis interview question covers various topics including programming, design patterns, data structures, and exception handling in Java.
Write a program to generate the Fibonacci series
Write a program using boolean variables
Explain the ClassCastException and how to handle it
Discuss the Singleton design pattern and its implementation with different JDK versions
Explain abstract classes and interfaces in your current project
Explain hashing in HashMap and the number of buckets
Differ...read more
Q55. What is a function and it's uses?
A function is a block of code that performs a specific task and can be called multiple times.
Functions help in modularizing code and making it reusable.
Functions can take parameters and return values.
Functions can be defined in different ways such as function declaration, function expression, arrow function, etc.
Examples of functions include Math.max(), console.log(), and document.getElementById().
Q56. Q1. Write a program to check whether the given String is pallindrome or not using two pointers approach in 3 mins?
Program to check if a given string is palindrome or not using two pointers approach.
Initialize two pointers, one at the start and one at the end of the string.
Compare the characters at both pointers and move them towards each other until they meet.
If all characters match, the string is a palindrome.
If any character doesn't match, the string is not a palindrome.
Q57. What is class, encapsulation and other feature of OOP?
Class is a blueprint for creating objects, encapsulation is the process of hiding data and methods within a class.
Class is a template or blueprint that defines the properties and behaviors of an object.
Encapsulation is the process of bundling data and methods together within a class, hiding the internal details from the outside world.
Other features of OOP include inheritance, polymorphism, and abstraction.
Inheritance allows a class to inherit properties and methods from anoth...read more
Q58. 2.Difference between Union and union all,drop and Truncate,star schema and snowflake schema,Dimension table and fact table.
Union combines the result sets of two or more SELECT statements, while Union All combines all rows from two or more SELECT statements.
Union removes duplicate rows, while Union All does not.
Union requires the number and order of columns in all SELECT statements to be the same, while Union All does not have this requirement.
Example: SELECT column1 FROM table1 UNION SELECT column1 FROM table2;
Example: SELECT column1 FROM table1 UNION ALL SELECT column1 FROM table2;
Q59. 1] Introduction 2] Explain automation framework in you project 3] Difference between Smoke, Sanity & Regression 4] Scenario based questions 5] Defect severity vs priority 6] BDD, Cucumber 7] Selenium basic ques...
read moreInterview questions for Programmer Analyst role
Explained automation framework used in the project
Differentiated between Smoke, Sanity & Regression testing
Answered scenario-based questions
Discussed defect severity vs priority
Explained BDD and Cucumber
Answered basic questions on Selenium
Q60. Ninja and His Secret Information Encoding Problem
Ninja, a new member of the FBI, has acquired some 'SECRET_INFORMATION' that he needs to share with his team. To ensure security against hackers, Ninja decides t...read more
The task is to determine if the encoding and decoding process of 'SECRET_INFORMATION' is successful.
Read the number of test cases 'T'
For each test case, encode the 'SECRET_INFORMATION' and then decode it
Compare the decoded string with the original 'SECRET_INFORMATION'
Print 'Transmission successful' if they match, else print 'Transmission failed'
Q61. Quick Sort Problem Statement
You are given an array of integers. Your task is to sort this array in ascending order using the Quick Sort algorithm.
Quick Sort utilizes a divide and conquer approach where a pivo...read more
Quick Sort is a divide and conquer algorithm that sorts an array in ascending order by choosing a pivot and partitioning the array into smaller subarrays.
Choose a pivot element from the array.
Partition the array into two subarrays - one with elements smaller than the pivot and one with elements larger than the pivot.
Recursively apply the same process on the subarrays until the entire array is sorted.
Complexity can be optimized to NlogN in the worst-case scenario.
Q62. Bottom View of Binary Tree
Given a binary tree, determine and return its bottom view when viewed from left to right. Assume that each child of a node is positioned at a 45-degree angle from its parent.
Nodes in...read more
Given a binary tree, determine and return its bottom view when viewed from left to right.
Traverse the binary tree level by level and keep track of the horizontal distance and depth of each node
For each horizontal distance, keep track of the node with the maximum depth
Return the nodes in the bottom view from left to right
Q63. Print Name and Age Problem Statement
Create a class named Person
with a string variable 'name'
and an integer variable 'age'
, such that these variables are not accessible outside the class. Implement a method t...read more
Create a class Person with private variables name and age, and methods to set and get their values.
Create a class Person with private variables 'name' and 'age'.
Implement a method setValue to set the variables' values.
Implement a method getValue to print the variables' values.
Ensure the name is a non-empty string and the age is a non-negative integer.
Encapsulate the data and provide a clear interface for setting and getting the values.
Q64. Rat In a Maze Problem Statement
Given a N * N
maze with a rat placed at position MAZE[0][0]
, find and print all possible paths for the rat to reach its destination at MAZE[N-1][N-1]
. The rat is allowed to move ...read more
The problem statement involves finding all possible paths for a rat to reach its destination in a maze.
Create a recursive function to explore all possible paths from the starting position to the destination.
Use backtracking to backtrack and explore other paths if the current path leads to a dead end.
Mark the cells visited by the rat with 1 and unvisited cells with 0 in the output path.
Ensure the rat can only move through cells marked as 1 in the maze.
Consider constraints such...read more
Q65. 1.Write a validation rule to bypass it for particular profile. 2.Write a trigger to update contact record upon account update. Write a soql query to fetch the contact records which do not have account.
Answering Salesforce Marketing Cloud Developer interview questions
To bypass validation rule for a particular profile, use the $Profile global variable in the rule formula
To update contact record upon account update, write a trigger on Account object and update related Contact records
To fetch contact records without account, use SOQL query with LEFT JOIN on Account object and WHERE clause to filter null values
Q66. Which type of Validation you will do at Landing and staging area.
At landing and staging area, I will perform data validation to ensure accuracy and completeness of data.
Validate data against source system
Check for missing or duplicate data
Verify data types and formats
Ensure data integrity and consistency
Perform data profiling and data quality checks
Q67. What are different types of algorthim methods in machine learning?
There are various algorithm methods in machine learning, such as supervised learning, unsupervised learning, and reinforcement learning.
Supervised learning: Algorithms learn from labeled data to make predictions or classifications.
Unsupervised learning: Algorithms learn from unlabeled data to discover patterns or relationships.
Reinforcement learning: Algorithms learn through trial and error to maximize rewards.
Other methods include semi-supervised learning, transfer learning,...read more
Q68. 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.
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
Q69. What is the difference between object storage and block storage?
Object storage stores data as objects while block storage stores data as blocks.
Object storage is ideal for unstructured data like images, videos, and documents.
Block storage is ideal for structured data like databases and virtual machines.
Object storage uses unique identifiers to access data while block storage uses block addresses.
Object storage is more scalable and cost-effective than block storage.
Examples of object storage include Amazon S3 and Google Cloud Storage while...read more
Q70. Tell us about NDAs/CDAs. What are the clauses?
NDAs/CDAs are legal agreements that protect confidential information shared between parties.
NDAs/CDAs stand for Non-Disclosure Agreements/Confidentiality Disclosure Agreements.
They are used to protect sensitive information from being disclosed to unauthorized parties.
The clauses in NDAs/CDAs typically include definitions of confidential information, obligations of the parties involved, duration of the agreement, and remedies for breach.
Examples of clauses in NDAs/CDAs include...read more
Q71. Maximum Product Subarray Problem Statement
Given an array arr
of integers, your task is to identify the contiguous subarray within the array which has the highest product of its elements. Return this maximum pr...read more
The task is to find the contiguous subarray within an array with the highest product of its elements.
Iterate through the array and keep track of the maximum and minimum product ending at each index.
Update the maximum product by considering the current element, maximum product ending at the previous index multiplied by the current element, and minimum product ending at the previous index multiplied by the current element.
Return the maximum product found during the iteration.
Ex...read more
Q72. Sum of Digits Problem Statement
Given an integer 'N', continue summing its digits until the result is a single-digit number. Your task is to determine the final value of 'N' after applying this operation iterat...read more
Given an integer 'N', find the final single-digit value by summing its digits iteratively.
Iteratively sum the digits of the given integer until the result is a single-digit number
Output the final single-digit integer for each test case
Follow the constraints provided in the problem statement
Q73. Binary Palindrome Check
Given an integer N
, determine whether its binary representation is a palindrome.
Input:
The first line contains an integer 'T' representing the number of test cases.
The next 'T' lines e...read more
Implement a function to determine if the binary representation of a given integer is a palindrome.
Convert the integer to binary representation
Check if the binary representation is a palindrome by comparing it with its reverse
Return true if it is a palindrome, false otherwise
Q74. your name in a database is repeated multiple number of types.To reduce it or to remove redundancy what do you do?
To remove redundancy in a database with repeated names, use normalization techniques.
Identify the primary key of the table and ensure it is unique
Create separate tables for related data to avoid repeating information
Use foreign keys to link related tables
Consider using indexing to improve performance
Update existing data to conform to the new structure
Q75. 1.Four pillars of OOPS concepts with real time example and have you used in your project or not? 2.Abstract class and interfaces with realtime example 3.Finalise and dispose method 4.Garbage collection in c# 5....
read moreInterview questions for Project Associate position covering OOPS concepts, MVC, ADO.NET, and SQL.
Four pillars of OOPS: Abstraction, Encapsulation, Inheritance, Polymorphism
Abstract class: Cannot be instantiated, can have abstract and non-abstract methods
Interfaces: Contract that defines a set of methods, can be implemented by classes
Finalize method: Called by garbage collector before object is destroyed
Dispose method: Used to release unmanaged resources, should be called expl...read more
Q76. If i want to select uncommon records which does not match how to pick?
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);
Q77. Write a program to display most frequent element in an array using Streams and Lambda expression. Difference between ArrayList and HashSet. What is the use of default method in interface? Difference between Str...
read moreAnswers to technical interview questions on Java programming language.
To display most frequent element in an array using Streams and Lambda expression, use Collectors.groupingBy() and Collectors.counting() methods.
ArrayList is an ordered collection of elements while HashSet is an unordered collection of unique elements.
Default methods in interface are used to provide a default implementation of a method that can be overridden by implementing classes.
StringBuffer is synchroniz...read more
Q78. LRU Cache Task Description
Design and implement a data structure for a Least Recently Used (LRU) cache to support two operations:
get(key)
- Returns the value for the given key if it exists in the cache, other...read more
Design and implement a Least Recently Used (LRU) cache data structure supporting get and put operations with specified constraints.
Implement a data structure for LRU cache with get and put operations
Maintain a capacity limit and remove least recently used item when exceeding capacity
Handle get operation by returning value for given key or -1 if key does not exist
Handle put operation by inserting or updating key-value pair in cache
Ensure time complexity is optimized for effici...read more
Q79. Left View of a Binary Tree Problem Statement
Given a binary tree, your task is to print the left view of the tree.
Example:
Input:
The input will be in level order form, with node values separated by a space. U...read more
Print the left view of a binary tree given in level order form.
Traverse the tree level by level and print the first node of each level
Use a queue to keep track of nodes at each level
Handle null nodes by using a placeholder value like -1
Q80. How do you change region your deployed AWS EC2 instance?
To change region of deployed AWS EC2 instance, create an AMI of the instance and launch it in the desired region.
Create an AMI of the instance in the current region
Copy the AMI to the desired region
Launch the copied AMI in the desired region
Q81. 1. Different types of schemas 2. Different types of slowly changing dimensions with real time examples used in our previous projects 3. Layers of ETL Testing and questions related to Staging layers 4. Report te...
read moreInterview questions for Senior Associate position in ETL Testing
Different types of schemas in ETL
Examples of slowly changing dimensions
Layers of ETL Testing and questions related to Staging layers
Types of reports and dashboard for report testing
Handling P1 defects in defect cycle
SQL queries with different scenarios
Q82. Do you know 4 pillars of OOP? Explain.
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 prevent external interference.
Inheritance: Creating new classes from existing ones, inheriting properties and methods.
Polymorphism: Using a single interface to represent multiple types of objects.
Q83. Explain me about OOPS Concepts. Write a program in C++ to calculate Fibonacci Series. Write a program in C ++ to calculate Factorial. What is Call by value, Call by reference? Explain abstraction, encapsulation...
read moreOOPS Concepts, Fibonacci Series, Factorial, Call by value/reference, Abstraction, Encapsulation, Polymorphism, Switch, Router, Hub, OSI Model
OOPS Concepts include inheritance, polymorphism, encapsulation, and abstraction
Example of Fibonacci Series program: int fib(int n) { return (n <= 1) ? n : fib(n-1) + fib(n-2); }
Example of Factorial program: int fact(int n) { return (n == 1 || n == 0) ? 1 : n * fact(n-1); }
Call by value passes a copy of the variable, while call by referen...read more
Q84. 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 moreThe 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.
Q85. What is the difference between variable and object?
Variables are names given to memory locations while objects are instances of a class with attributes and methods.
Variables are used to store values while objects are used to represent real-world entities.
Variables can be reassigned to different values while objects have a fixed identity.
Variables are created when they are assigned a value while objects are created using constructors.
Variables can be of different data types while objects are instances of a specific class.
Examp...read more
Q86. How do you avoid re-rendering of a component? With useEffect second parameter, should ComponentUpdate
To avoid re-rendering, use shouldComponentUpdate or React.memo
Use shouldComponentUpdate to compare current and next props/state
Use React.memo to memoize functional components
Use useMemo to memoize expensive computations
Use useCallback to memoize event handlers
Use PureComponent for class components
Q87. If there are 10 ball 2 red, 5 blue ,3 orange and one ball is picked randomly what is probability that the ball picked is red?
What is the probability of picking a red ball out of 10 balls with 2 red, 5 blue, and 3 orange?
There are 2 red balls out of 10 total balls
The probability of picking a red ball is 2/10 or 1/5
The probability can also be expressed as 20%
Q88. Subarray Sums I Problem Statement
You are provided with an array of positive integers ARR
that represents the strengths of different “jutsus” (ninja techniques). You are also given the strength of the enemy S
, ...read more
Count the number of subarrays whose combined strength matches the given enemy strength.
Iterate through the array and maintain a running sum to check for subarrays with sum equal to the enemy strength.
Use a hashmap to store the running sum frequencies and increment the count of subarrays accordingly.
Return the count of subarrays that sum up to the given enemy strength.
Q89. Encode the Message Problem Statement
Given a text message, your task is to return the Run-length Encoding of the given message.
Run-length encoding is a fast and simple method of encoding strings, representing ...read more
Implement a function to encode a text message using run-length encoding.
Iterate through the message and count consecutive characters
Append the character and its count to the encoded message
Handle edge cases like single characters or empty message
Q90. What are availability zones and regions in AWS?
Availability zones and regions are geographical locations in AWS data centers.
Availability zones are isolated locations within a region that contain their own power, cooling, and networking infrastructure.
Regions are separate geographic areas that consist of two or more availability zones.
Each region is completely independent and isolated from the others.
Customers can deploy resources in multiple availability zones to achieve high availability and fault tolerance.
Examples of ...read more
Q91. How to solve the problem if your team mate is underperforming
Address underperformance of team mate by identifying root cause and providing support.
Have a conversation with the team mate to understand the root cause of underperformance
Provide support and resources to help the team mate improve
Set clear expectations and goals for the team mate
Monitor progress and provide feedback regularly
Consider involving a supervisor or HR if the issue persists
Q92. Where do you rate your programming skills on a scale of 1 to 10?
I rate my programming skills at 8 out of 10.
I have experience in multiple programming languages such as Java, Python, and C++.
I have completed several projects including a web application and a mobile app.
I am constantly learning and improving my skills through online courses and personal projects.
Q93. Merge Sort Problem Statement
You are given a sequence of numbers, ARR
. Your task is to return a sorted sequence of ARR
in non-descending order using the Merge Sort algorithm.
Explanation:
The Merge Sort algorit...read more
Implement Merge Sort algorithm to sort a sequence of numbers in non-descending order.
Understand the Merge Sort algorithm which involves dividing the array into two halves, sorting each half, and then merging them back together.
Recursively apply the Merge Sort algorithm until the base case of having a single element in the array is reached.
Merge the sorted halves back together in a way that maintains the non-descending order of the elements.
Ensure to handle the input constrain...read more
Q94. Imagine there are 7 people in the room and there are 7 apples in the basket. Everyone took one apple still one left in the basket. How?
One apple is still left in the basket because one of the people in the room is the owner of the basket and did not take an apple.
One person in the room is the owner of the basket
The owner did not take an apple
Hence, one apple is still left in the basket
Q95. What is S3? What are the difference classes in S3?
S3 is a cloud-based object storage service provided by Amazon Web Services (AWS).
S3 stands for Simple Storage Service.
It allows users to store and retrieve data from anywhere on the web.
S3 offers different storage classes such as Standard, Infrequent Access, and Glacier.
Standard is for frequently accessed data, Infrequent Access is for data that is accessed less frequently, and Glacier is for long-term archival storage.
S3 also provides features like versioning, lifecycle poli...read more
Q96. Which programming languages you're comfortable with ?
Q97. If we have to return table, how to create a stored procedure?
To create a stored procedure that returns a table, use SELECT statement within the procedure.
Create a stored procedure using CREATE PROCEDURE statement.
Within the procedure, use SELECT statement to query the data and return the table.
Specify the columns to be returned in the SELECT statement.
Execute the stored procedure to retrieve the table data.
Q98. Write a query to find the employee name who earns maximum salary
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.
Q99. What is Object oriented programming? What are the 4 principal of Object oriented programming?
Object oriented programming is a programming paradigm that focuses on objects and their interactions to solve problems.
Encapsulation: bundling data and methods that operate on that data within a single unit.
Inheritance: creating new classes from existing ones, inheriting their properties and methods.
Polymorphism: the ability of objects to take on many forms, allowing them to be used in different ways.
Abstraction: hiding implementation details and only showing the necessary in...read more
Q100. 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.
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
More about working at Cognizant







Top HR Questions asked in Cognizant
Interview Process at Cognizant

Top Interview Questions from Similar Companies








Reviews
Interviews
Salaries
Users/Month

