Curated interview practice questions with answers. These are practice scenarios, not a verified list of past interview questions.
About Accenture hiring for Java roles
Accenture is a global professional services company offering strategy, consulting, technology, operations and digital services. India hosts a large share of its workforce, delivering software engineering, testing, cloud, data and AI projects for clients worldwide. It hires freshers and experienced professionals in India for associate software engineer, test engineer, data analyst and analytics consultant roles.
For Java roles, this Accenture practice set focuses most on Collections Framework (7), Java 8+ Features and Streams (5), Strings and Exception Handling (4), Spring Boot and Microservices (4). It has 9 easy, 18 medium, 3 hard questions, so you can start easy and work up to the harder ones.
Company type
Consulting
Headquarters
Dublin, Ireland
Main India offices
Bengaluru, Hyderabad, Pune, Mumbai, Gurugram
Accenture Java interview process
Online assessment (cognitive + technical MCQs)
Coding assessment
Communication assessment
Technical and HR interview
Typical pattern based on public candidate experiences. Rounds vary by role, team and year.
Solved for AccentureStart 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
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.
02
What is the difference between JPA, Hibernate and Spring Data JPA?
JPA, now Jakarta Persistence, is a specification of interfaces and annotations for object relational mapping. Hibernate is the most popular implementation of that specification and adds its own features. Spring Data JPA sits on top and generates repository implementations from interfaces and method names like findByEmail, reducing boilerplate. Your code uses JPA annotations, Hibernate does the work and Spring Data simplifies access.
03
Explain the hierarchy of the Java Collections Framework.
The root interface is Iterable, then Collection, which has List (ordered, allows duplicates: ArrayList, LinkedList), Set (unique: HashSet, LinkedHashSet, TreeSet) and Queue/Deque (PriorityQueue, ArrayDeque). Map is separate and stores key-value pairs: HashMap, LinkedHashMap, TreeMap and ConcurrentHashMap. Java 21 added SequencedCollection and SequencedMap with getFirst() and getLast().
04
Memory usage is high because millions of Integer objects are stored in an ArrayList. What would you do?
Each Integer is a separate object with header overhead and a reference, so a List of Integer uses several times more memory than the raw data. If size is known, use an int[] array. Otherwise use primitive collections from libraries such as Eclipse Collections or fastutil, which store ints directly. This also improves cache performance and reduces GC pressure.
05
Implement the Builder pattern for a User class with many optional fields.
A builder avoids long constructors.
public class User {
private final String name; private final int age;
private User(Builder b) { name = b.name; age = b.age; }
public static class Builder {
private String name; private int age;
public Builder name(String n) { name = n; return this; }
public Builder age(int a) { age = a; return this; }
public User build() { return new User(this); }
}
}
Usage: new User.Builder().name("Asha").age(25).build(). Lombok @Builder generates this.
The string pool is a special area in the heap where string literals are stored once and reused. String a = "hi" and String b = "hi" point to the same object. new String("hi") creates a separate heap object, and intern() returns the pooled copy. Pooling saves memory because many strings in apps repeat, such as status codes and keys.
07
Why must you be careful when initial capacity of a HashMap is too small?
If a HashMap starts small and grows large, it resizes many times; each resize allocates a new array and rehashes every entry, which costs CPU and creates garbage. When the expected size is known, use HashMap.newHashMap(n) in Java 19 or later, or set capacity to n divided by 0.75. Too large a capacity wastes memory, so size it to real data.
08
Flatten a list of lists of integers and compute the sum of squares of the even numbers.
flatMap then use a primitive stream to avoid boxing.
int result = lists.stream()
.flatMap(List::stream)
.filter(n -> n % 2 == 0)
.mapToInt(n -> n * n)
.sum();
mapToInt returns an IntStream, whose sum() is simpler and faster than reduce on boxed Integers.
Try-with-resources, from Java 7, automatically closes any object that implements AutoCloseable when the try block ends, even if an exception is thrown. Resources close in reverse order of opening. If both the body and close() throw, the close exception is added as a suppressed exception. It replaces long finally blocks for files, JDBC connections and streams.
10
An API calls three independent downstream services one after another and takes 900 ms. How would you speed it up?
Since the calls are independent, run them in parallel with CompletableFuture.supplyAsync on a dedicated executor or with virtual threads, then join with allOf. Total latency becomes roughly the slowest call, about 300 ms. Add a timeout per call with orTimeout and a fallback for failures so one slow service does not block the whole response. Structured concurrency is another option in newer Java.
11
toMap() throws Duplicate key exception in production. How do you fix it?
The data has repeated keys that the developer assumed were unique. Decide the business rule, then pass a merge function, for example toMap(User::email, u -> u, (a, b) -> a) to keep the first, or use groupingBy if all values are needed. Also check upstream data quality, since duplicates may signal a deeper bug such as missing unique constraints.
12
Bind typed configuration properties with validation in Spring Boot.
Use a record with @ConfigurationProperties.
@ConfigurationProperties(prefix = "payment")
@Validated
public record PaymentProps(
@NotBlank String baseUrl,
@Min(100) int timeoutMs) {}
// application.yml
// payment:
// base-url: https://pay.internal
// timeout-ms: 2000
Enable it with @ConfigurationPropertiesScan on the main class. The app fails at startup if values are invalid.
13
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.
14
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.
15
Legacy code uses anonymous classes and loops everywhere. How would you modernise it safely?
First add tests around the behaviour. Then refactor in small steps: anonymous Comparators and Runnables become lambdas, simple loops that filter and transform become streams, and null checks around returns become Optional where useful. Keep complex loops with early exits as loops if a stream is less readable. Use IDE refactorings and review each change to avoid altering behaviour.
16
You must expose configuration that differs between dev, QA and production. How do you manage it?
Use Spring profiles with application-dev.yml and application-prod.yml, and bind settings to typed @ConfigurationProperties classes with validation. Keep secrets out of the repo by injecting them through environment variables, Kubernetes Secrets or a vault. Activate the profile with SPRING_PROFILES_ACTIVE in each environment. Use the same build artefact everywhere and change only configuration.
17
A log file shows a NullPointerException only for some users. How do you debug it?
Start with the stack trace; since Java 14 helpful NPE messages name exactly which variable was null. Reproduce with the failing user's data, which often has an optional field missing. Fix the root cause by validating input at the boundary, using Optional for values that may be absent and annotating with @NonNull. Add a unit test for that data case so it does not return.
18
Your REST API returns stack traces to clients when errors happen. How do you design proper error handling?
Never expose stack traces; they leak internals. In Spring Boot use a @RestControllerAdvice with @ExceptionHandler methods that map domain exceptions to status codes, such as 404 for not found and 400 for validation. Return a consistent body, ideally RFC 7807 ProblemDetail, with a code, message and trace id. Log full details on the server with the same trace id.
19
A HashMap shared by many threads sometimes loses updates. How do you fix it?
HashMap is not thread safe, so concurrent put calls can overwrite each other. Replace it with ConcurrentHashMap and use atomic methods instead of get-then-put, for example counts.merge(key, 1, Integer::sum) or computeIfAbsent for lazy creation. Collections.synchronizedMap also works but locks the whole map, which hurts throughput under contention.
20
You have to process tasks in order of priority. Which collection do you use?
Use PriorityQueue, a binary heap where poll() always returns the smallest element by natural order or by a Comparator, such as Comparator.comparingInt(Task::priority). Insert and poll are O(log n) and peek is O(1). For multiple threads use PriorityBlockingQueue. Iterating a PriorityQueue does not give sorted order; only repeated poll() does.
21
Describe a time you had to learn a new technology quickly.
Situation: I joined a project using reactive Spring WebFlux with no prior experience. Task: contribute within two weeks. Action: I studied Project Reactor basics, built a small practice service, paired with a senior on my first ticket and kept notes on common operators. Result: I delivered my first feature in the second week and later wrote the team guide on avoiding blocking calls in reactive code.
22
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.
23
Write a simple REST controller in Spring Boot for creating and fetching products.
Use a shared lock with wait and notify.
class Printer {
int n = 1;
synchronized void print(boolean odd) throws InterruptedException {
while (n <= 10) {
if ((n % 2 == 1) == odd) {
System.out.println(Thread.currentThread().getName() + " " + n++);
notifyAll();
} else wait();
}
notifyAll();
}
}
Start one thread with print(true) and another with print(false).
25
An API listing 100 orders fires 101 SQL queries. How do you fix it?
This is the N+1 problem from a lazy association loaded in a loop or by JSON serialisation. Fetch what the endpoint needs in one query with JOIN FETCH or @EntityGraph(attributePaths = "items"), or use a DTO projection query. For collections with pagination, fetch ids first, then fetch associations in a second query to avoid in-memory paging. Add a test that asserts the query count.
26
Clients report duplicate orders when they retry after a timeout. How do you prevent it?
Make the create order API idempotent. The client sends an Idempotency-Key header; the server stores the key with the result in a table with a unique constraint or in Redis. A retry with the same key returns the saved response instead of creating a new order. Database unique constraints on business keys add another safety net.
27
What is the Liskov Substitution Principle? Give an example of breaking it.
LSP says any subclass object must be usable wherever the parent is expected without breaking behaviour. A classic violation is Square extends Rectangle: setting width also changes height, so code that sets width 5 and height 4 and expects area 20 fails. Another is a subclass throwing UnsupportedOperationException for a parent method. The fix is a better hierarchy or composition.
28
Join a list of names into a comma separated string with brackets using streams.
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.
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.
Tips to crack the Accenture Java interview
Practise the communication assessment, which checks spoken English through reading, listening and repeating sentences in a recorded format.
Revise MS Office, cloud basics, networking and pseudocode, as Accenture technical MCQs often cover these general IT topics.
Read about Accenture's focus on cloud, data and AI and be ready to discuss how you would work in client-facing teams.
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; Accenture interviewers usually ask follow-ups on your first answer.
Frequently asked questions
How many rounds are there in the Accenture Java interview?
Candidates usually go through 4 stages: Online assessment (cognitive + technical MCQs); Coding assessment; Communication assessment; Technical and HR interview. 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 Accenture Java interview?
This practice set leans on Collections Framework (7), Java 8+ Features and Streams (5), Strings and Exception Handling (4), Spring Boot and Microservices (4). Revise those first, then practise explaining one or two of your own projects end to end, because most Accenture interviewers ask you to walk through real work.
Are these the exact questions asked at Accenture?
No. These are curated practice questions that match the skills and difficulty usually tested in consulting interviews like Accenture's. They are not a leaked or verified list of past questions.
Where does Accenture hire Java professionals in India?
Accenture has large teams in Bengaluru, Hyderabad, Pune, Mumbai, Gurugram. Openings and locations change often, so check the Accenture careers page and filter by city and experience.