Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
About LTIMindtree hiring for Java roles
LTIMindtree is an Indian IT services and consulting company formed by the merger of Larsen and Toubro Infotech and Mindtree, and part of the L&T Group. It provides cloud, data, ERP, testing and digital engineering services for global clients. It hires for software engineers, test engineers, data analysts, data engineers and ERP consultants.
For Java roles, this LTIMindtree practice set focuses most on Java Basics and JVM (7), Collections Framework (6), OOP in Java (5), Multithreading and Concurrency (4). It has 13 easy, 16 medium, 1 hard questions, so you can start easy and work up to the harder ones.
Company type
IT services
Headquarters
Mumbai, India
Main India offices
Mumbai, Pune, Bengaluru, Chennai, Hyderabad
LTIMindtree Java interview process
Online assessment (aptitude + reasoning)
Coding test
Technical interview
HR round
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for LTIMindtreeStart practicing
3 QUESTIONS FREESign up to unlock the full question bank and track your progress.Unlock every question and answer, then continue practising company-wise and package-wise.
✓ 3 questions free • Unlock the rest in seconds
01
What is the difference between a static and an instance variable?
A static variable belongs to the class, so there is only one copy shared by all objects, and it is created when the class is loaded. An instance variable belongs to each object and gets a separate copy per instance. A counter of created objects should be static, while a customer's name should be an instance field.
Optional is a container that may or may not hold a value, used mainly as a method return type to show that a result can be absent, for example findById. Use map, filter, orElse, orElseGet and orElseThrow instead of calling get() blindly. Do not use Optional for fields, parameters or collections, and prefer orElseGet when the default is costly to create.
Transient: a new object not yet linked to a persistence context. Managed (persistent): attached to the context, so changes are tracked and flushed automatically through dirty checking. Detached: was managed but the context closed or it was evicted; changes are not tracked until merge(). Removed: scheduled for deletion on flush. persist, merge, detach and remove move entities between these states.
04
What is the difference between HashMap, LinkedHashMap and TreeMap?
HashMap gives O(1) average operations with no ordering guarantee. LinkedHashMap keeps insertion order, or access order if configured, which helps build an LRU cache. TreeMap keeps keys sorted by natural order or a Comparator with O(log n) operations and supports range methods like floorKey and headMap. HashMap allows one null key; TreeMap does not allow null keys with natural ordering.
05
What is the difference between composition and inheritance, and which should you prefer?
Inheritance is an is-a relation where the subclass reuses parent code, but it creates tight coupling and fragile hierarchies. Composition is a has-a relation where a class holds another object and delegates work, such as a Car having an Engine. Prefer composition because it is flexible, allows changing behaviour at runtime and is easier to test. Use inheritance only for a true is-a relationship.
06
What is the difference between == and equals() in Java?
== compares primitive values, or for objects it checks whether two references point to the same object in memory. equals() checks logical equality and can be overridden, as String, Integer and most value classes do. For example, new String("a") == new String("a") is false, but equals() returns true. Always use equals() to compare object content.
07
Write a Java solution for the Two Sum problem using a HashMap.
Store each number's index and look up its complement.
public int[] twoSum(int[] nums, int target) {
Map<Integer, Integer> seen = new HashMap<>();
for (int i = 0; i < nums.length; i++) {
Integer j = seen.get(target - nums[i]);
if (j != null) return new int[]{j, i};
seen.put(nums[i], i);
}
return new int[0];
}
One pass, O(n) time and O(n) space.
A functional interface has exactly one abstract method, so it can be implemented with a lambda or method reference. It may also have default and static methods. Examples are Runnable, Comparator, and those in java.util.function: Function, Predicate, Consumer, Supplier and BiFunction. The @FunctionalInterface annotation makes the compiler enforce the single abstract method rule.
09
What is the difference between wait() and sleep()?
wait() is an Object method called inside synchronized code; it releases the monitor and waits until notify(), notifyAll() or a timeout. sleep() is a Thread static method that pauses the current thread for a time but keeps any locks it holds. wait() is for coordination between threads, while sleep() simply delays. Modern code prefers Condition, BlockingQueue or CountDownLatch.
10
What are the four pillars of OOP? Explain with Java examples.
Encapsulation hides data behind methods, for example private fields with getters and setters in a BankAccount class. Abstraction exposes only what is needed through abstract classes or interfaces, like a Payment interface. Inheritance lets a class reuse another, such as SavingsAccount extends Account. Polymorphism lets one reference behave differently, like a Payment variable calling pay() on a UpiPayment or CardPayment.
11
What are records in Java and when should you use them?
Records, final in Java 16, are concise classes for immutable data. record Point(int x, int y) {} generates private final fields, a canonical constructor, accessors, equals(), hashCode() and toString(). You can add validation in a compact constructor and add methods. Use them for DTOs, API responses and map keys. They cannot extend another class and are not suited to JPA entities, which need mutability.
12
Tell me about a time you found and fixed a difficult production bug in a Java application.
Situation: our order service crashed with OutOfMemoryError every few days. Task: find the root cause without long downtime. Action: I enabled heap dumps on OOM, analysed the dump in Eclipse MAT and found a static HashMap used as a cache that was never cleared. I replaced it with a bounded Caffeine cache with expiry and added a heap usage alert. Result: no crashes in six months and memory stayed flat.
13
What is the difference between synchronized and ReentrantLock?
synchronized is a built-in keyword that locks a monitor and releases it automatically at block exit. ReentrantLock is an explicit lock that adds tryLock with timeout, interruptible locking, fairness options and multiple Condition objects, but you must unlock in a finally block. Both are reentrant. Prefer synchronized for simple cases and ReentrantLock when you need its extra features.
14
Write a unit test for a service class using JUnit 5 and Mockito.
Mock the repository and verify behaviour.
@ExtendWith(MockitoExtension.class)
class ProductServiceTest {
@Mock ProductRepository repo;
@InjectMocks ProductService service;
@Test
void throwsWhenMissing() {
when(repo.findById(1L)).thenReturn(Optional.empty());
assertThrows(NotFoundException.class, () -> service.get(1L));
verify(repo).findById(1L);
}
}
No Spring context starts, so the test runs in milliseconds.
15
Write Java code to reverse an integer without converting it to a string.
Take the last digit with % 10 and build the result, checking for overflow.
public static int reverse(int x) {
long rev = 0;
while (x != 0) {
rev = rev * 10 + x % 10;
x /= 10;
}
if (rev > Integer.MAX_VALUE || rev < Integer.MIN_VALUE) return 0;
return (int) rev;
}
Negative numbers work because % keeps the sign in Java.
Count with a map, then keep a min-heap of size K.
Map<String, Integer> cnt = new HashMap<>();
for (String w : words) cnt.merge(w, 1, Integer::sum);
PriorityQueue<String> pq = new PriorityQueue<>(
Comparator.comparingInt(cnt::get));
for (String w : cnt.keySet()) {
pq.offer(w);
if (pq.size() > k) pq.poll();
}
Time O(n log k). Reverse the heap contents for highest first.
17
What is the difference between checked and unchecked exceptions?
Checked exceptions extend Exception (but not RuntimeException) and must be caught or declared with throws, for example IOException and SQLException. Unchecked exceptions extend RuntimeException, such as NullPointerException and IllegalArgumentException, and need no declaration. Use checked exceptions for recoverable conditions callers must handle and unchecked ones for programming errors. Errors like OutOfMemoryError should not be caught.
18
An API needs to find the price band for any amount, for example the nearest lower slab. Which structure fits?
TreeMap is ideal because it keeps keys sorted and offers navigation methods. Store slab start amounts as keys and the band as value, then floorEntry(amount) returns the largest slab not above the amount in O(log n). ceilingKey, headMap and tailMap help with similar range queries such as tax slabs or delivery charges.
19
When would you choose ArrayDeque over Stack and LinkedList?
Stack is a legacy synchronized class built on Vector, so it is slow and exposes index methods that break stack rules. LinkedList allocates a node per element. ArrayDeque is a resizable circular array with no per-element allocation, so push, pop, offer and poll are fast amortised O(1). Use ArrayDeque for both stacks and queues in single-threaded code; it does not accept null.
volatile guarantees visibility and ordering: a write to a volatile field is immediately visible to other threads, and it prevents reordering around that access under the Java Memory Model. It does not make compound operations like count++ atomic, because that is a read, modify and write. Use it for flags such as a stop signal, and use AtomicInteger or locks for counters.
21
Write code that runs 10,000 blocking tasks using virtual threads.
Use the virtual-thread-per-task executor in Java 21.
try (var ex = Executors.newVirtualThreadPerTaskExecutor()) {
for (int i = 0; i < 10_000; i++) {
int id = i;
ex.submit(() -> {
Thread.sleep(Duration.ofMillis(200));
return id;
});
}
} // close() waits for all tasks
All tasks finish in about 200 ms because blocked virtual threads free their carriers.
22
How do you handle disagreement with a reviewer about your code?
Situation: a senior reviewer asked me to replace my checked exceptions with unchecked ones. Task: decide the right approach without conflict. Action: I asked for the reasons, read our codebase conventions and wrote a small comparison, then agreed because unchecked exceptions fit our global handler. Result: the change merged the same day and I learned to check team conventions before designing error handling.
23
What is the difference between Comparable and Comparator?
Comparable defines a class's natural ordering through compareTo() inside the class, such as String sorted alphabetically. Comparator is a separate object with compare(), so you can define many orderings without changing the class. Java 8 made Comparator easy: Comparator.comparing(Employee::getSalary).reversed().thenComparing(Employee::getName). TreeMap and sort methods accept either.
24
Why does Java not support multiple inheritance of classes?
Multiple inheritance of classes creates the diamond problem: if two parents have the same method with different code, the child cannot know which one to use, and state duplication becomes messy. Java avoids this by allowing one superclass but many interfaces. If two interfaces provide the same default method, the class must override it and can call a specific one with InterfaceName.super.method().
25
What is the difference between static and dynamic binding?
Static binding is resolved at compile time and applies to private, static and final methods and to overloaded methods, because the compiler knows exactly which method to call. Dynamic binding is resolved at runtime based on the actual object type and applies to overridden instance methods. Static methods are hidden, not overridden, so the reference type decides which one runs.
26
What is the N+1 select problem in Hibernate and how do you fix it?
N+1 happens when you load N parent entities with one query and then a lazy association triggers one extra query per parent, giving N+1 queries. Fix it with a JOIN FETCH in JPQL, an @EntityGraph on the repository method, or batch fetching with @BatchSize or hibernate.default_batch_fetch_size. Detect it by enabling SQL logging or using a query count assertion in tests.
The JVM first interprets bytecode, then profiles which methods run often. The Just In Time compiler converts these hot methods into optimised native code at runtime. HotSpot uses tiered compilation: C1 compiles quickly with light optimisation and C2 applies aggressive optimisations like inlining and escape analysis. This is why Java apps get faster after a warm-up period.
28
A team member compares two Integer values with == and the check fails only for large numbers. Explain.
Integer.valueOf caches objects for values from -128 to 127, so autoboxed small numbers share the same object and == returns true. Larger values create new Integer objects, so == compares two different references and returns false. The fix is to use equals() or compare unboxed int values. Static analysis tools like SonarQube flag this pattern.
29
What is a ClassLoader and what is the delegation model?
A ClassLoader loads .class files into the JVM. The main loaders are Bootstrap (core classes), Platform (formerly Extension) and Application (classpath). In the parent delegation model a loader first asks its parent to load a class and only loads it itself if the parent cannot. This prevents user code from replacing core classes like java.lang.String.
Count characters with an array for lowercase letters.
public static boolean isAnagram(String a, String b) {
if (a.length() != b.length()) return false;
int[] count = new int[26];
for (int i = 0; i < a.length(); i++) {
count[a.charAt(i) - 'a']++;
count[b.charAt(i) - 'a']--;
}
for (int c : count) if (c != 0) return false;
return true;
}
O(n) time; use a HashMap for Unicode input.
Tips to crack the LTIMindtree Java interview
Practise aptitude, logical reasoning and basic coding questions, as the online assessment is usually the first filter.
Revise SQL, OOP and testing fundamentals, plus any cloud or data tools you list on your resume.
Learn about the L&T Group background and the LTI and Mindtree merger to answer company-related questions.
Keep a one-minute story ready for every project on your CV: problem, your part, tools, result.
Practise the hard questions on this page aloud; LTIMindtree interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the LTIMindtree Java interview?
Candidates usually go through 4 stages: Online assessment (aptitude + reasoning); Coding test; Technical interview; HR round. The exact rounds change with the role, team, location and your experience, so confirm the process with the recruiter.
Which topics should I prepare for the LTIMindtree Java interview?
This practice set leans on Java Basics and JVM (7), Collections Framework (6), OOP in Java (5), Multithreading and Concurrency (4). Revise those first, then practise explaining one or two of your own projects end to end, because most LTIMindtree interviewers ask you to walk through real work.
Are these the exact questions asked at LTIMindtree?
No. These are curated practice questions that match the skills and difficulty usually tested in it services interviews like LTIMindtree's. They are not a leaked or verified list of past questions.
Where does LTIMindtree hire Java professionals in India?
LTIMindtree has large teams in Mumbai, Pune, Bengaluru, Chennai, Hyderabad. Openings and locations change often, so check the LTIMindtree careers page and filter by city and experience.