Tech Mahindra · engineering
Preparation guide for Java Developer positions at Tech Mahindra. Covers their Aptitude → Technical + HR process with technical, behavioral, and HR questions.
What is the difference between `==` and `.equals()` in Java?
Tip: `==` compares object references (memory addresses). `.equals()` compares logical content — overridden in String and most value classes. Classic trap: `new String("a") == new String("a")` is false; `.equals()` is true.
What are the key features introduced in Java 8?
Tip: Lambda expressions, Stream API, Optional class, functional interfaces, default/static interface methods, new Date-Time API (java.time), and CompletableFuture. Streams and lambdas are the most commonly tested.
What is the difference between ArrayList and LinkedList in Java?
Tip: ArrayList: O(1) random access, O(n) insert/delete at middle. LinkedList: O(n) access, O(1) insert/delete at head/tail. Use ArrayList by default; LinkedList only when you frequently add/remove at ends and never random-access.
What are checked and unchecked exceptions in Java? When do you use each?
Tip: Checked exceptions (extend Exception) must be declared or caught — for recoverable conditions like file not found. Unchecked (extend RuntimeException) are for programming errors (NPE, ArrayIndexOutOfBounds). Do not catch RuntimeException broadly.
What are the SOLID principles? Give a one-line Java example for each.
Tip: S: Single Responsibility — one class, one reason to change. O: Open/Closed — extend via inheritance, not modification. L: Liskov Substitution — subclasses must be substitutable. I: Interface Segregation — small focused interfaces. D: Dependency Inversion — depend on abstractions.
What is multithreading in Java? Explain `synchronized`, `volatile`, and when you use each.
Tip: `synchronized` acquires a monitor lock — prevents concurrent access to a block. `volatile` ensures a variable is read from main memory, not a thread-local cache — no atomicity guarantee. Use `volatile` for single-write flags; `synchronized` for compound operations.
Explain Spring Boot auto-configuration. How does it work under the hood?
Tip: @SpringBootApplication triggers @EnableAutoConfiguration. Spring Boot scans META-INF/spring.factories, finds @Configuration classes, and applies them conditionally using @ConditionalOnClass/@ConditionalOnMissingBean. The app gets sensible defaults without XML.
Tell me about a Spring Boot application you built. What design decisions are you most proud of?
Tip: Name a specific technical choice: service layer separation, DTO pattern, exception handler with @ControllerAdvice, custom validation. Tie it to the problem it solved, not just "it follows best practices."
A Java service is throwing OutOfMemoryError in production at peak traffic. What is your approach?
Tip: Immediate: increase heap (-Xmx), take heap dump (jmap), restart if needed. Analysis: load heap dump in Eclipse MAT or VisualVM, find largest retained set. Common causes: unbounded caches, session leaks, large result sets loaded into memory. Fix root cause.
What is garbage collection in Java? Explain generational GC.
Tip: GC automatically reclaims unused heap memory. Generational GC: most objects die young (Eden). Young Gen: minor GC, fast. Old Gen: major GC, slower. G1GC (Java 9+ default) divides heap into regions for predictable pause times.
What is the difference between HashMap and HashTable in Java?
Tip: HashMap is non-synchronised (faster, not thread-safe), allows one null key. HashTable is synchronised (thread-safe but slow), no null keys. Prefer ConcurrentHashMap over HashTable in multithreaded code.
Java vs Python — for a high-throughput, low-latency backend service, which would you choose and why?
Tip: Java: JVM JIT compilation, mature concurrency primitives, type safety. Python: GIL limits true parallelism, but async frameworks (FastAPI) excel for I/O-bound workloads. Show you understand the trade-off — neither is universally better.
Take a full scored mock interview tailored to your resume. Get feedback on technical depth, clarity, structure, confidence, and relevance — free to start.