1. Why are immutable types (e.g., String) favored for keys and thread safety?
Stable hashCode/equality avoids map/key corruption; no internal state changes simplify reasoning and eliminate data races.
Get the Preplance app for a seamless learning experience. Practice offline, get daily streaks, and stay ahead with real-time interview updates.
Get it on
Google Play
4.9/5 Rating on Store
Tech Mahindra · Java
Practice Java questions specifically asked in Tech Mahindra interviews – ideal for online test preparation, technical rounds and final HR discussions.
Questions
8
Tagged for this company + subject
Company
Tech Mahindra
View company-wise questions
Subject
Java
Explore topic-wise practice
Go through each question and its explanation. Use this page for targeted revision just before your Tech Mahindra Java round.
Stable hashCode/equality avoids map/key corruption; no internal state changes simplify reasoning and eliminate data races.
Collection(List/Set/Queue/Deque) and Map; e.g., ArrayList, HashSet, ArrayDeque, HashMap.
Comparable defines a natural order in the class itself; Comparator supplies alternative or external orderings without changing the class.
Abstract class for shared state/base implementation and ctor control; interface for capability types, multiple inheritance of behavior (default/static).
sealed ... permits ... restricts the subclassing hierarchy for better design and exhaustiveness.
Overloading is compile-time (choose method by signature); overriding is runtime (dispatch by actual object).
Sealed types control extension points, improving maintainability and exhaustiveness checks.
The JIT compiles frequently executed methods/loops to native code for speed.
For complete preparation, combine this company + subject page with full company-wise practice and subject-wise practice. You can also explore other companies and topics from the links below.