Publicis Sapient
400+ Magma HDI General Insurance Interview Questions and Answers
Q1. Make Array Elements Equal Problem Statement
Given an integer array, your objective is to change all elements to the same value, minimizing the cost. The cost of changing an element from x
to y
is defined as |x ...read more
Q2. Merge Two Sorted Lists (In-Place) Problem Statement
You are given two sorted linked lists. Your task is to merge them to form a combined sorted linked list and return the head of this final linked list.
Example...read more
Q3. pirates of different ages have a treasure of 100 gold coins. On their ship, they decide to split the coins using this scheme: The oldest pirate proposes how to share the coins, the OTHER pirates (not including...
read moreThe oldest pirate proposes to keep 98 coins for himself and give 1 coin to each of the other pirates.
The oldest pirate will propose to keep the majority of the coins for himself to ensure the vote passes.
The other pirates will vote in favor of the proposal to avoid being thrown overboard.
The proposed distribution will be 98 coins for the oldest pirate and 1 coin for each of the other pirates.
Q4. Reverse Linked List Problem Statement
Given a singly linked list of integers, return the head of the reversed linked list.
Example:
Initial linked list: 1 -> 2 -> 3 -> 4 -> NULL
Reversed linked list: 4 -> 3 -> 2...read more
Q5. Merge K Sorted Arrays Problem Statement
Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.
Input
The f...read more
Q6. There are 10 black socks and 10 white socks in a drawer. You have to go out wearing your shoes. So how many maximum number of times you need to remove a sock from drawer so that you can go out? You can remove o...
read moreQ7. Add Two Numbers as Linked Lists
You are given two singly linked lists, where each list represents a positive number without any leading zeros.
Your task is to add these two numbers and return the sum as a linke...read more
Q8. Maximum 1s in a Row Problem
Given a matrix ARR
with dimensions N
* M
, consisting only of 0s and 1s where each row is sorted, determine the index of the row that contains the highest number of 1s. If multiple ro...read more
Q9. 3 men go into a hotel. The man behind the desk says a room is $30 so each man pays $10 and goes to the room. A while later the man behind the desk realized the room was only $25 so he sent the bellboy to the 3...
read moreQ10. Count Subarrays with XOR=X Problem Statement
You are given an array of integers 'ARR' and an integer 'X'. Your task is to determine the number of subarrays in 'ARR' whose elements have a bitwise XOR equals to '...read more
Q11. Longest Palindromic Substring Problem Statement
You are provided with a string STR
of length N
. The goal is to identify the longest palindromic substring within this string. In cases where multiple palindromic ...read more
Q12. Largest Rectangle in Histogram Problem Statement
You are given an array/list HEIGHTS
of length N
, where each element represents the height of a histogram bar. The width of each bar is considered to be 1.
Your t...read more
Q13. Three friends rent a room for Rs.30 by paying Rs.10 each. The owner decides to give them a discount Rs.5 and gives it to the broker. The broker who a cunning man takes Rs.2. and returns one rupee to each of the...
read moreThe missing rupee is not actually missing. The calculation is misleading and does not account for the total amount paid.
The initial amount paid by each person was Rs.10, totaling Rs.30.
The owner gave them a discount of Rs.5, so they paid Rs.25 in total.
The broker took Rs.2, leaving them with Rs.23.
When the broker returned Rs.1 to each person, they each received Rs.1 back, totaling Rs.3.
So, the total amount paid by the three friends is Rs.25 + Rs.3 = Rs.28.
The remaining Rs.2 i...read more
Q14. Quick Sort Algorithm
Sort the given array of integers in ascending order using the quick sort algorithm.
Explanation:
Quick sort is a divide and conquer algorithm where a pivot is chosen to partition the array ...read more
Q15. Next Greater Element Problem Statement
You are given an array arr
of length N
. For each element in the array, find the next greater element (NGE) that appears to the right. If there is no such greater element, ...read more
Q16. You have three bags and three labels. One bag has only red balls, one has only blue balls and one has both red and blue balls. Three labels are R, B and RB. R label was meant for the bag with only red balls, B...
read moreQ17. Trapping Rain Water Problem Statement
You are given a long type array/list ARR
of size N
, representing an elevation map. The value ARR[i]
denotes the elevation of the ith
bar. Your task is to determine the tota...read more
Q18. Permutations Problem Statement
Given an array of distinct integers, generate and return all the possible permutations of the array.
Example:
Input:
ARR = [1, 2]
Output:
[[1, 2], [2, 1]]
Explanation:
The array h...read more
Q19. Count Substrings with K Distinct Characters
Given a lowercase string 'STR' and an integer K, the task is to count all possible substrings that consist of exactly K distinct characters. These substrings are not ...read more
Q20. Cycle Detection in Undirected Graph Problem Statement
You are provided with an undirected graph containing 'N' vertices and 'M' edges. The vertices are numbered from 1 to 'N'. Your objective is to determine whe...read more
Q21. You have three bags and three labels. One bag has only apples, one has only oranges and one has both apples and oranges. Three labels are Ap,Or and ApOr.Ap label was meant for the bag with only Apples, Or label...
read moreQ22. Merge Two Sorted Arrays Problem Statement
Given two sorted integer arrays ARR1
and ARR2
of size M and N, respectively, merge them into ARR1
as one sorted array. Assume that ARR1
has a size of M + N to hold all ...read more
The task is to merge two sorted arrays into one sorted array.
Create a new array with size M + N to store the merged array
Use two pointers to iterate through the elements of ARR1 and ARR2
Compare the elements at the current pointers and add the smaller element to the new array
Move the pointer of the array from which the element was added
Repeat the process until all elements are merged
If there are remaining elements in ARR2, add them to the new array
Return the merged array
Q23. Line Reflection Problem Statement
You are given several sets of points on a 2D plane, each set represented as a list of coordinates. Your task is to determine if there exists a line parallel to the Y-axis that ...read more
Q24. You are given 2 eggs.You have access to a 100-storey sapient building.Eggs can be very hard or very fragile means it may break if dropped from the first floor or may not even break if dropped from 100 th floor....
read moreQ25. String Ka Khel Problem Statement
Ninja is creating a new game ‘String Ka Khel’ for his gaming shop. In this game, players are given ‘N’ strings. The objective is to find the maximum length of strings that can b...read more
Q26. Maximum Subarray Sum Problem Statement
Given an array ARR
consisting of N
integers, your goal is to determine the maximum possible sum of a non-empty contiguous subarray within this array.
Example of Subarrays:...read more
Q27. Reverse a Linked List Problem Statement
Given a singly linked list of integers, your task is to return the head of the reversed linked list.
Example:
Input:
The given linked list is 1 -> 2 -> 3 -> 4-> NULL.
Out...read more
Q28. 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
Q29. Longest Repeating Substring Problem Statement
Given a string str
consisting of lowercase English alphabet letters, and an integer K
, you are allowed to perform at most K
operations on this string. An operation ...read more
Q30. Valid Parentheses Problem Statement
Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.
Input:
The first line contains an integer...read more
Q31. Height of a Binary Tree
You are provided with an arbitrary binary tree consisting of 'N' nodes where each node is associated with a certain value. The task is to determine the height of the tree.
Explanation:
T...read more
The height of a binary tree is the maximum number of edges from the root to a leaf node.
Traverse the tree recursively and keep track of the maximum height
If the current node is null, return 0
Otherwise, calculate the height of the left and right subtrees and return the maximum height plus 1
Q32. You are at an unmarked intersection… one way is the City of Lies and another way is the City of Truth. Citizens of the City of Lies always lie. Citizens of the City of Truth always tell the truth. A citizen of...
read moreAsk 'Which way would someone from the other city point to?'
Ask the person which way they would point if they were from the other city
If they are from the City of Truth, they would point towards the City of Truth
If they are from the City of Lies, they would also point towards the City of Truth
Q33. Rajeev is trapped at top a building 200m high. He has with him a rope 150m long. There is a hook at the top where he stands. Looking down, he notices that midway between him and the ground, at a height of 100m,...
read moreQ34. Minimum Cost Path Problem Statement
Given an N x M
matrix filled with integers, determine the minimum sum obtainable from a path that starts at a specified cell (x, y)
and ends at the top left corner of the mat...read more
Q35. You are given a match-box and two candles of equal size, which can burn 1 hour each. You have to measure 90 minutes with these candles. (There is no scale or clock). How do you do?
Use one candle as a timer and the other to measure 90 minutes.
Light both candles at the same time.
Let one candle burn for 30 minutes.
Then light the other candle.
When the second candle burns out, 90 minutes have passed.
The first candle will have burned for 60 minutes, serving as a timer.
Q36. 0/1 Knapsack Problem Statement
A thief plans to rob a store and can carry a knapsack with a maximum weight capacity of 'W'. The store contains 'N' items, each with a specified weight and value known to the thie...read more
Q37. Stack using Two Queues Problem Statement
Develop a Stack Data Structure to store integer values using two Queues internally.
Your stack implementation should provide these public functions:
Explanation:
1. Cons...read more
Q38. Valid Parenthesis Problem Statement
Given a string str
composed solely of the characters "{", "}", "(", ")", "[", and "]", determine whether the parentheses are balanced.
Input:
The first line contains an integ...read more
Q39. You have two ropes/candels. Each takes exactly 60 minutes to burn. They are made of different material so even though they take the same amount of time to burn, they burn at separate rates. In addition, each ro...
read moreQ40. I was to imagine a situation where there’s is an empty wet, water spilled room(ceiling to floor height- 12 ft), a dead man(7 ft height) hung by a 3 ft rope. I’m asked how could the man hung himself there?
The man stood on a block of ice, which melted and caused him to hang himself.
The man stood on a block of ice that was placed in the room.
Over time, the block of ice melted, causing the man to hang himself.
The length of the rope was initially longer than 3 ft, but as the ice melted, the rope became shorter.
The water from the melted ice filled the room, making it wet.
Q41. • What is Data Extensions? How it is different from Lists? • What is A/B testing and how to perform A/B Testing? • How do you filter data in Date extension? • What are Automation Studio Activities? • Can you ex...
read moreQuestions related to Salesforce Marketing Cloud features and functionalities.
Data Extensions are tables that store data in Marketing Cloud, while Lists are simple collections of subscribers.
A/B testing is a method of comparing two versions of a campaign to determine which one performs better.
Data in Data Extensions can be filtered using SQL queries or Filter Activities in Automation Studio.
Automation Studio Activities are pre-built actions that can be used to automate marketi...read more
Q42. 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
Q43. If I give you 4 tablets which contain 2 for fever and 2 for cold.All 4 have same size, shape and color, No cover. You have to take 1 cold and 1 fever tablet right now. How will you choose correctly?
Q44. You have 4 wine bottles, one of which is poisoned. You want to determine which bottle is poisoned by feeding the wines to the rats. How many minimum rats are necessary to find the poisoned bottle?
Q45. Character Pattern Problem Statement
Generate a pattern based on the input number of rows N. Each row i should start with the i-th letter of the alphabet, and the number of letters in the row should match the ro...read more
Q46. You are given a 100 integers and these integers are in the range of 1 to 100. There are no duplicates in list. One of the integers is missing.Find the missing integer. What if 2 no is missing?
Q47. How many runs a single player can score in One day match (50 overs/ 300 balls)… No ‘no balls’, no wides, no extras, no over throws.So how much runs he can score max?
Q48. You have 8 balls which are identical(completely). You are given a weighing scale. How many times would you measure to get the odd ball out?
Weighing 3 times is enough to find the odd ball out.
Divide the balls into 3 groups of 3 each and weigh any 2 groups against each other.
If they are equal, the odd ball is in the third group. Weigh 2 balls from that group to find the odd one.
If they are not equal, the odd ball is in the heavier group. Weigh 2 balls from that group to find the odd one.
Q49. An unsorted array has numbers. Find the duplicate numbers and return the array.
Find duplicate numbers in an unsorted array and return the array.
Iterate through the array and keep track of seen numbers using a hash table.
If a number is already in the hash table, it is a duplicate.
Add the duplicate number to a new array and return it.
Q50. How to you reverse a string without using any looping and inbuilt functions?
To reverse a string without using any looping and inbuilt functions, we can use recursion.
Create a function that takes a string as input.
If the length of the string is 0 or 1, return the string.
Otherwise, call the function recursively with the substring starting from the second character and concatenate the first character at the end.
Return the reversed string.
Example: reverseString('hello') returns 'olleh'.
Q51. What is a SSR and CSR website and when to use which one.
SSR and CSR websites refer to server-side rendering and client-side rendering respectively. SSR is used for better initial load performance and SEO, while CSR is suitable for dynamic and interactive content.
SSR (Server-Side Rendering) websites render the web pages on the server and send the fully rendered HTML to the client.
CSR (Client-Side Rendering) websites load a minimal HTML skeleton and then use JavaScript to fetch data and render the content on the client-side.
SSR is b...read more
Q52. There are three ants on three corners of an equilateral triangle. they can move in any direction but only along the triangle edges. probability that any two ants collide each other
The probability of two ants colliding on an equilateral triangle is 1/3.
Each ant has an equal chance of moving towards either of the other two ants.
There are three possible scenarios where two ants can collide out of a total of nine possible scenarios.
Therefore, the probability of two ants colliding is 1/3.
Q53. What is limit for no of arguments passed to functions? if limit is 10 den how to pass more parameters? Ans:- either Array or Structure
The limit for the number of arguments passed to functions is not fixed. Arrays or structures can be used to pass more parameters.
The limit for the number of arguments passed to functions is not fixed and depends on the programming language and system architecture.
In C programming language, there is no limit on the number of arguments that can be passed to a function.
In Java, the maximum number of arguments that can be passed to a method is 255.
To pass more parameters than the...read more
Q54. If I am ready to accept a project in Java, if Sapient had trained you in DotNet earlier
I would be ready to accept a project in Java even if I was trained in DotNet earlier.
I have a strong foundation in programming principles and concepts, which can be applied to any language.
I am confident in my ability to quickly learn and adapt to new technologies.
I have experience working with multiple programming languages and frameworks.
I can leverage my knowledge of DotNet to understand similar concepts in Java.
I am motivated and enthusiastic about taking on new challenge...read more
Q55. How do you cut a circular cake into eight equal pieces in just 3 cuts?
Q57. Explain Clean Architecture, how it works?
Clean Architecture is a software design principle that separates concerns and promotes testability, maintainability, and scalability.
Clean Architecture emphasizes separation of concerns by dividing the codebase into layers: Presentation, Domain, and Data.
Each layer has its own responsibilities and dependencies flow inward, ensuring loose coupling and high cohesion.
The Presentation layer handles user interactions and UI components.
The Domain layer contains business logic and u...read more
Q58. In stack push & pop opration take O(1) time. Write function FindMin() which finds minimum element in stack with O(1) time complexity
Use an auxiliary stack to keep track of minimum element at each level of the main stack.
Create an auxiliary stack to keep track of minimum element at each level of the main stack.
When pushing an element onto the main stack, compare it with the top element of the auxiliary stack and push the smaller one onto the auxiliary stack.
When popping an element from the main stack, also pop the top element from the auxiliary stack.
The top element of the auxiliary stack will always be th...read more
Q59. Without lifting the pen meet 9 point arranged in squre of 3×3, using 4 lines?
Connect 9 points in a 3x3 square using 4 lines without lifting the pen.
Start at any point and draw a line to the adjacent point
Continue drawing lines until all points are connected
Make sure the lines intersect to form a square
Q60. If you had to accommodate a CR in agile how would you do so?
To accommodate a CR in agile, the business analyst should follow a process that includes evaluating the impact, prioritizing, estimating effort, and incorporating the change into the sprint.
Evaluate the impact of the change request on the project scope, timeline, and resources.
Prioritize the change request based on its urgency and importance.
Estimate the effort required to implement the change and communicate it to the stakeholders.
Discuss the change request with the developm...read more
Q61. How many queues will you use to implement a priority queue?
A priority queue can be implemented using a single queue or multiple queues.
One approach is to use a single queue and assign priorities to elements using a separate data structure.
Another approach is to use multiple queues, each representing a different priority level.
For example, if there are three priority levels, three queues can be used to implement the priority queue.
Q63. 1. Explain oops concepts in coding. 2. Write a program to find missing no in a list 3. Write a program to count the alphabets in a string. 4. Explain project framework from scratch 5. Explain selenium code 6. B...
read moreThe interview questions cover OOP concepts, coding exercises, project frameworks, Selenium automation, BDD with Cucumber, and TestNG.
OOP concepts include inheritance, encapsulation, polymorphism, and abstraction.
Example: Inheritance - a class 'Car' can inherit properties from a class 'Vehicle'.
To find missing number in a list, iterate through the list and check for gaps in sequence.
Example: List {1, 2, 4, 5} - Missing number is 3.
To count alphabets in a string, iterate throug...read more
Q64. There is 2 pot one red and one blue. one pot contains tressure. Two statement are given 1. only one of the statement is correct. 2. Blue pot has the tressure. Find the tressure?
The treasure is in the red pot.
The statement 'only one of the statement is correct' means that one statement is true and the other is false.
If the blue pot has the treasure, then both statements would be true, which contradicts the given information.
Therefore, the statement 'Blue pot has the treasure' must be false, and the treasure must be in the other pot, which is the red pot.
Q66. If all players of a cricket team were out first ball, which player would be the last person not out?
Q67. What are the different meetings that happen in Agile style development?
Different meetings in Agile style development include daily stand-up, sprint planning, sprint review, and retrospective.
Daily stand-up: A short daily meeting where team members discuss their progress, plans, and any obstacles.
Sprint planning: A meeting at the beginning of each sprint to determine the work to be done and set priorities.
Sprint review: A meeting at the end of each sprint to demonstrate completed work to stakeholders and gather feedback.
Retrospective: A meeting a...read more
Q68. Which datastructure would you use to implement an heteregenous array?
An array of objects can be used to implement a heterogeneous array.
Each element in the array can be an object that represents a different data type.
The objects can have different properties and methods based on their respective data types.
For example, an element can be an object representing a string with a 'value' property and a 'length' method.
Q69. I was given 9 balls which all are identical except one which is hollow! How many trials would you take to figure out the hollow one!
It would take a maximum of 3 trials to figure out the hollow ball.
Divide the balls into 3 groups of 3 balls each.
Weigh 2 groups against each other. If one group is lighter, move to next step.
Weigh 2 balls from the lighter group. The lighter ball is the hollow one.
Q70. What will happen if job has failed in pipeline and data processing cycle is over?
If a job fails in the pipeline and data processing cycle is over, it can lead to incomplete or inaccurate data.
Incomplete data may affect downstream processes and analysis
Data quality may be compromised if errors are not addressed
Monitoring and alerting systems should be in place to detect and handle failures
Re-running the failed job or implementing error handling mechanisms can help prevent issues in the future
Q71. What would be duration of a sprint and who leads it?
The duration of a sprint is typically 2-4 weeks and it is led by the Scrum Master or Agile Coach.
A sprint is a time-boxed iteration in Agile development.
The duration of a sprint is determined by the team, but it is usually between 2-4 weeks.
During a sprint, the team works on a set of prioritized user stories or tasks.
The Scrum Master or Agile Coach is responsible for leading the sprint and ensuring that the team follows the Agile principles and practices.
They facilitate the s...read more
Q72. Who is a stake holder and how do you classify them?
Stakeholders are individuals or groups who have an interest or influence in a project or organization.
Stakeholders can include employees, customers, suppliers, shareholders, government agencies, and community members.
They can be classified into internal stakeholders (e.g., employees, shareholders) and external stakeholders (e.g., customers, suppliers).
Stakeholders can also be categorized based on their level of influence or interest in the project.
Some stakeholders may have h...read more
Q74. What is difference between Static and Global Vaiable?
Static variables have local scope but retain their value between function calls, while global variables have global scope.
Static variables are declared inside a function and retain their value between function calls
Global variables are declared outside of any function and can be accessed from any part of the program
Static variables have local scope, while global variables have global scope
Static variables are initialized only once, while global variables are initialized at th...read more
Q75. What is difference between if else and switch case statements?
if else is used for simple conditions while switch case is used for multiple conditions.
if else is a sequential decision-making statement while switch case is a multi-branch decision-making statement
if else is used when there are only a few conditions to be checked while switch case is used when there are multiple conditions to be checked
if else can have multiple conditions in a single statement while switch case can only have one condition per case
if else is more readable an...read more
Q76. What are the documents that you had to create during the process
Various documents are created during the business analysis process.
Business requirements document (BRD)
Functional requirements document (FRD)
Use case document
Process flow diagrams
Data flow diagrams
User stories
Test plans
Training materials
Project charter
Risk assessment document
Q77. How garbage collector identifies which object it should pick?
Garbage collector identifies objects to pick based on their reachability.
Garbage collector starts from a set of root objects and identifies all objects that are reachable from them.
Objects that are not reachable are considered garbage and are eligible for collection.
Reachability is determined by following object references from root objects.
Objects that are referenced by other reachable objects are also considered reachable.
Objects that are not referenced by any reachable obj...read more
Q78. Out of 8 balls one is less in weight find no of times u will use the scale to determine which one is defective?
You will use the scale 2 times to determine which ball is defective.
First, divide the 8 balls into 3 groups - 3 balls, 3 balls, and 2 balls.
Weigh the first two groups of 3 balls against each other. If they balance, the defective ball is in the group of 2 balls.
If one group of 3 balls is lighter, weigh two of those balls against each other. If they balance, the defective ball is the third ball.
If one group of 3 balls is heavier, weigh two of those balls against each other. The...read more
Q79. Create a Login form and validate email input using Vanilla JS.
Create a Login form with email validation using Vanilla JS.
Create a form in HTML with input fields for email and password
Use JavaScript to validate the email input using regular expressions
Display error messages if the email input is not in the correct format
Q80. Can you describe the difference between FRD and BRD?
FRD and BRD are both documents used in the software development process, but they serve different purposes.
FRD stands for Functional Requirements Document and describes the functional requirements of a software system.
BRD stands for Business Requirements Document and outlines the business needs and objectives that the software system should fulfill.
FRD focuses on the specific functionalities and features of the software, while BRD focuses on the overall business goals and req...read more
Q81. What is the difference between C and C++?
C++ is an extension of C with object-oriented programming features.
C++ supports classes and objects while C does not.
C++ has better support for polymorphism and inheritance.
C++ has a standard template library (STL) which C does not have.
C++ allows function overloading while C does not.
C++ has exception handling while C does not.
Q83. Draw a system diagram for ecommers system to place an order and get order history for a particular customer
System diagram for e-commerce order placement and history retrieval
Frontend: Customer interface for browsing products, adding to cart, and placing orders
Backend: Order processing system to handle order placement, payment processing, and order fulfillment
Database: Store customer information, order details, and order history for retrieval
APIs: Communication between frontend, backend, and database for seamless order processing
Analytics: Track order history and customer behavior ...read more
Q84. 1. remove duplicate from the list of object
Remove duplicates from a list of objects.
Create a new empty list.
Iterate through the original list.
For each object, check if it is already in the new list.
If not, add it to the new list.
Return the new list without duplicates.
Q85. What is the difference between for and while loop?
For loop is used for iterating over a sequence while while loop is used for iterating until a condition is met.
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
For loop is faster than while loop for iterating over a sequence
While loop is useful for iterating until a specific condition is met
For loop can be used with range() function to iterate over a sequence
While loop can be used with br...read more
Q86. How to enhance web performance of a page.
To enhance web performance of a page, optimize images, minify code, reduce server response time, use caching, and enable compression.
Optimize images by compressing them and using appropriate file formats.
Minify code by removing unnecessary characters and whitespace.
Reduce server response time by using a content delivery network (CDN) and optimizing database queries.
Use caching to store frequently accessed data and reduce server requests.
Enable compression to reduce file sizes...read more
Q87. Diffrences between list and tuples, OOPS concepts, Decorators, Mutable vs Immutable, list and tuple which is faster, lamda, reduce, filter,generators and iter objects.
Lists and tuples are both data structures in Python, but lists are mutable while tuples are immutable. OOP concepts include inheritance, encapsulation, and polymorphism. Decorators are used to modify functions or methods. Lambda functions are anonymous functions. Reduce, filter, generators, and iter objects are all related to functional programming in Python.
Lists are mutable, meaning they can be changed after creation. Tuples are immutable, meaning they cannot be changed aft...read more
Q88. Plant 10 plants in 5 rows such that each row has 4 plants
10 plants can be planted in 5 rows with 4 plants in each row.
Divide the plants into groups of 4.
Arrange the groups in 5 rows.
Each row will have 4 plants.
Q89. How to verify code before at compile time?
Code can be verified before compile time using static code analysis tools.
Static code analysis tools can detect potential bugs, security vulnerabilities, and coding errors before compilation.
Examples of static code analysis tools include SonarQube, Checkstyle, and PMD.
These tools can be integrated into the development process to ensure code quality and reduce the risk of errors.
Static code analysis can also help enforce coding standards and best practices.
Regular use of stati...read more
Q90. What is the difference between Function definition and declaration
Function definition specifies the implementation of a function, while declaration provides the function signature.
Function definition includes the function body, while declaration only includes the function signature.
Function definition is used to define the behavior of a function, while declaration is used to announce the existence of a function.
Function definition can only appear once in a program, while declaration can appear multiple times.
Example of function definition: ...read more
Q91. what are 3 steps for using function in c?
Three steps for using functions in C.
Declare the function with its return type, name, and parameters.
Define the function by writing the code for it.
Call the function by using its name and passing arguments if necessary.
Q92. What is a stack and various operations on it?
A stack is a data structure that follows the Last In First Out (LIFO) principle.
Push: adds an element to the top of the stack
Pop: removes the top element from the stack
Peek: returns the top element without removing it
IsEmpty: checks if the stack is empty
Size: returns the number of elements in the stack
Q93. Difference between method overloading and methode overriding ?
Method overloading is having multiple methods with the same name but different parameters. Method overriding is having a subclass method with the same name and parameters as a superclass method.
Method overloading is used to provide different ways of calling the same method with different parameters.
Method overriding is used to provide a specific implementation of a method in a subclass that is already defined in the superclass.
Method overloading is resolved at compile-time ba...read more
Q94. Difference between switch case and if else statement?
Switch case is used for multiple conditions while if else is used for binary conditions.
Switch case is faster than if else for multiple conditions.
If else can handle complex conditions while switch case cannot.
Switch case can only compare values of the same data type.
If else can handle null values while switch case cannot.
Example: switch (day) { case 1: console.log('Monday'); break; case 2: console.log('Tuesday'); break; default: console.log('Invalid day'); }
Example: if (age ...read more
Q95. Sorting the list of strings based on the count of their occurrences/
Sorting a list of strings based on their occurrence count.
Create a dictionary to store the count of each string.
Use the dictionary to sort the list based on the count of occurrences.
If two strings have the same count, sort them alphabetically.
Return the sorted list.
Q96. How to swap numbers without using temporary variable
Swapping numbers without using a temporary variable
Use addition and subtraction to swap the numbers
Example: a = 5, b = 10. a = a + b (15), b = a - b (5), a = a - b (10)
Alternatively, use bitwise XOR operation to swap the numbers
Example: a = 5, b = 10. a = a ^ b (15), b = a ^ b (5), a = a ^ b (10)
Q97. what is function overloading and overriding (difference between them)
Function overloading and overriding are concepts in object-oriented programming.
Function overloading is when multiple functions with the same name but different parameters are defined in a class.
Function overriding is when a derived class provides a different implementation for a method that is already defined in the base class.
Overloading is resolved at compile-time based on the number, type, and order of arguments, while overriding is resolved at runtime based on the object...read more
Q98. Write a Java String program to replace the characters. Write a Java program for Encapsulation. What is the difference between Comparator and Comparable? In between an Interview, the screen was abruptly closed....
read moreJava String program to replace characters, Encapsulation program, Comparator vs Comparable difference
For Java String program to replace characters, use the replace() method to replace specific characters in a string.
For Encapsulation in Java, use private access modifiers to restrict access to class variables and use public getter and setter methods to access and modify them.
Comparator and Comparable are interfaces used for sorting objects in Java. Comparable is implemented by...read more
Q99. 1. Program for Inserting random number in an array and then sort in ascending and descending order. 2. Dynamic x path related questions 3. Maven related questions 4. TestNG annotations..etc 5. Program for rever...
read moreQ100. Is JavaScript a statically typed or dynamically typed language?
JavaScript is a dynamically typed language.
Variables can hold different data types at different times
Type checking is done at runtime
Example: var x = 5; x = 'hello';
Top HR Questions asked in Magma HDI General Insurance
Interview Process at Magma HDI General Insurance
Top Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month