Indian IT services
Mastech Digital Java Developer Interview: Rounds, Questions and Preparation
For Java Developer roles at companies like Mastech Digital
What the job involves
A Java Developer at Indian IT services firms like Mastech Digital typically works on building and maintaining enterprise applications for clients, often in banking, insurance, or healthcare domains. Day to day you write Java code, fix bugs, participate in daily stand-ups, and coordinate with senior developers and testers. Freshers usually start on support or enhancement projects before moving to core development.
Role and Technical Knowledge
- 1
Explain the difference between an abstract class and an interface in Java, and when you would use each in a service layer.
Mention that abstract classes allow shared state and partial implementation, while interfaces define contracts. Give an example like using an interface for a PaymentService and an abstract class for a BaseService with common logging.
- 2
How does a HashMap work internally in Java, and why is it important for performance in enterprise applications?
Cover hashing, buckets, equals and hashCode contracts, and collision handling with linked lists or trees. Link it to faster lookups in caching or session management.
- 3
What is the difference between a REST API and a SOAP web service, and which one would you choose for a new microservice at a services company?
Highlight REST's lightweight JSON, statelessness, and ease of use with Spring Boot. Mention SOAP for legacy or strict contract needs, but prefer REST for new client projects.
- 4
Explain how you would handle a NullPointerException in a Java application that processes customer orders.
Talk about using Optional, defensive checks, and logging. Mention writing a unit test to reproduce the issue and validating input at the controller layer.
Practical Scenarios
- 5
You are asked to add a new field to an existing REST endpoint that returns customer data. Walk me through your steps.
Start by understanding the data model and updating the DTO or entity. Then modify the service and controller, update tests, and check backward compatibility for existing clients.
- 6
A client reports that a Java batch job is running slow and timing out every night. How would you debug it?
Mention checking logs, database query performance with EXPLAIN, memory usage, and thread dumps. Suggest adding timing logs and optimizing the slowest query or loop.
- 7
You need to connect a Spring Boot application to a MySQL database. What configuration and code changes do you make?
Cover adding the MySQL connector and Spring Data JPA dependency, setting spring.datasource properties in application.properties, and creating a repository interface.
- 8
How would you handle a situation where your code works on your local machine but fails on the client's test server?
Compare environment differences like Java version, database schema, and configuration files. Check logs on the server, verify dependencies, and use a consistent build tool like Maven.
Behavioural and HR
- 9
Why do you want to join a mid-sized IT services company like Mastech Digital instead of a large product company?
Show interest in client-facing work, faster learning across domains, and the chance to take ownership early. Avoid saying it is just a backup option.
- 10
Describe a time you had to learn a new technology quickly for a college project or internship.
Use the STAR method. Pick a specific example like learning Spring Boot for a final year project, and mention the resources you used and the outcome.
- 11
Are you comfortable working in rotational shifts or relocating to a client location anywhere in India?
Be honest but positive. If you are flexible, say so and give a reason like wanting exposure to different projects. If not, explain your constraints clearly.
- 12
Tell me about a time you disagreed with a teammate on a technical approach. How did you resolve it?
Focus on listening, presenting data or a small proof of concept, and agreeing on the best solution for the project. Avoid blaming the teammate.
Coding and Fundamentals
- 13
Write a Java program to reverse a string without using the built-in reverse method.
Use a loop or StringBuilder. Explain time complexity O(n) and handle null or empty input. Mention that StringBuilder is more efficient than string concatenation.
- 14
Given an array of integers, find the second largest element. Explain your approach.
Sort the array or do a single pass tracking largest and second largest. Discuss edge cases like duplicates and arrays with fewer than two elements.
- 15
What is the difference between == and .equals() in Java? Give an example where using == causes a bug.
== compares references for objects, .equals() compares content. Use a String example like new String("abc") == "abc" returning false, and explain when to override equals and hashCode.
- 16
Explain checked vs unchecked exceptions and when you would create a custom exception in a Spring Boot service.
Checked exceptions are compile-time and used for recoverable conditions. Unchecked are runtime. Create a custom exception like OrderNotFoundException to return a clear API error.
Coding round
Java Developer interviews usually include a coding round. Practise planning the solution out loud, then review code the AI writes from your plan, in Python, Java, C++, C or JavaScript.
Ready to try it for real?
Take a timed test or talk through a mock interview for this role, then see your scores.
This is practice material for Java Developer roles, written with AI. It is not a list of questions Mastech Digital or any other company has asked.