Tech Mahindra interview experience Real time questions & tips from candidates to crack your interview

Software Engineer

Tech Mahindra
upvote
share-icon
1 rounds | 5 Coding problems

Interview preparation journey

expand-icon
Preparation
Duration: 5 months
Topics: React JS, Java, Data Structures, Algorithms, System Design, OOPS
Tip
Tip

Tip 1 : Must do Previously asked Interview as well as Online Test Questions.
Tip 2 : Go through all the previous interview experiences from Codestudio and Leetcode.
Tip 3 : Do practice improving the time complexity of the code. Be confident.

Application process
Where: Other
Eligibility: Above 7 CGPA
Resume Tip
Resume tip

Tip 1 : Have at-least 2 good projects explained in short with all important points covered.
Tip 2 : Every skill must be mentioned.
Tip 3 : Focus on skills, projects and experiences more.

Interview rounds

01
Round
Easy
Video Call
Duration60 minutes
Interview date20 Oct 2020
Coding problem5

Technical Interview round with questions on DSA, Java and React.

1. Print characters and their frequencies in order of occurrence

Easy
15m average time
85% success
0/40
Asked in companies
AmazonTata Consultancy Services (TCS)Tech Mahindra

You are given a string 'S' of length 'N', you need to find the frequency of each of the characters from ‘a’ to ‘z’ in the given string.

Example :

Given 'S' : abcdg
Then output will be : 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
Problem approach

1. Create a count array to store the frequency of each character in the given string.
2. Traverse the string again and check whether the frequency of that character is 0 or not.
3. If not 0, then print the character along with its frequency and update its frequency to 0 in the hash table. This is done so that the same character is not printed again.
Time Complexity: O(n), where n is the number of characters in the string. 
Auxiliary Space: O(1), as there are only lowercase letters.

Try solving now

2. Java Question

What is method hiding?

Problem approach

Method hiding can be defined as, "if a subclass defines a static method with the same signature as a static method in the super class, in such a case, the method in the subclass hides the one in the superclass." The mechanism is known as method hiding. It happens because static methods are resolved at compile time.

3. React Question

How do we pass data from one component to another in React?

Problem approach

We have multiple ways of passing data among components. We can pass data from parent to child, from child to parent, and between siblings.
Passing data from Parent to Child:
For passing data from parent to child component, we use props. Props data is sent by the parent component and cannot be changed by the child component as they are read-only.

Passing data from Child to Parent Component:
For passing the data from the child component to the parent component, we have to create a callback function in the parent component and then pass the callback function to the child component as a prop. This callback function will retrieve the data from the child component. The child component calls the parent callback function using props and passes the data to the parent component.

Passing data between Siblings:
For passing data among siblings, there are multiple methods:
Combination of the above two methods (callback and use of props).
Using Redux.
ContextAPI

4. React Question

What are the phases of each component of React lifecycle?

Problem approach

Each component in React has a lifecycle which you can monitor and manipulate during its three main phases.
The three phases are: Mounting, Updating, and Unmounting.

1. Mounting means putting elements into the DOM.
React has four built-in methods that gets called, in this order, when mounting a component:
constructor()
getDerivedStateFromProps()
render()
componentDidMount()

2. The next phase in the lifecycle is when a component is updated.
A component is updated whenever there is a change in the component's state or props.
React has five built-in methods that gets called, in this order, when a component is updated:
getDerivedStateFromProps()
shouldComponentUpdate()
render()
getSnapshotBeforeUpdate()
componentDidUpdate()

3.The next phase in the lifecycle is when a component is removed from the DOM, or unmounting as React likes to call it.
React has only one built-in method that gets called when a component is unmounted:
componentWillUnmount()

5. React Question

How does React works in the background when the state changes?

Problem approach

When a component’s props or state change, React decides whether an actual DOM update is necessary by comparing the newly returned element with the previously rendered one. When they are not equal, React will update the DOM.

Here's your problem of the day

Solving this problem will increase your chance to get selected in this company

Skill covered: Programming

What is 3 + 2 * 4 based on operator precedence?

Choose another skill to practice
Similar interview experiences
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Tech Mahindra
0 views
0 comments
0 upvotes
company logo
Software Engineer
2 rounds | 4 problems
Interviewed by Tech Mahindra
0 views
0 comments
0 upvotes
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Tech Mahindra
2057 views
1 comments
0 upvotes
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Tech Mahindra
1279 views
1 comments
0 upvotes
Companies with similar interview experiences
company logo
Software Engineer
4 rounds | 1 problems
Interviewed by Newgen Software
2695 views
2 comments
0 upvotes
company logo
Software Engineer
3 rounds | 6 problems
Interviewed by HashedIn
2040 views
0 comments
0 upvotes
company logo
Software Engineer
2 rounds | 2 problems
Interviewed by Ernst & Young (EY)
0 views
0 comments
0 upvotes