The most difficult Java questions you might find in a bank interview
More than a quarter of technology jobs in banking involve Java. Getting in, however, requires more than (just) Leetcode practice. It will involve an in-depth discussion with your interviewer about various Java techniques and principles, both mainstream and niche.
💥Follow us on WhatsApp for news alerts.💥
We've looked at interview experiences listed on Glassdoor across each of the major banks. Discussions ranged wildly and involved all of the following topics:
- lambda expressions
- streams
- indexing
- caching
- collection
- abstract classes/interfaces
- functional interfaces
- unit testing
- multithreading
- modifiers
- Selenium automation frameworks
- Spring Boot
- Hash Map
Different banks will ask a range of questions to allow you to explore these concepts and others. We've collected 16 questions below that were reported by Glassdoor users when interviewing at specific banks.
Conversational Java interview questions in banks
How can you implement defensive security in a Java application (Goldman Sachs)
How do you identify memory leaks in Java (TD)
How do you tune the Java Virtual Machine for performance optimisation? (TD)
Why should you implement equals() and hashcode() for custom objects? (Goldman Sachs)
What is the difference between ArrayList and LinkedList (JPMorgan)
What do you know about the collection interface? (Morgan Stanley)
What is object in java? What are interfaces? (Morgan Stanley)
How do you query from one or more sql tables? (Morgan Stanley)
What is the technique to optimally query from a huge database? (Morgan Stanley)
What’s a constructor in Java? (Morgan Stanley)
How do you improve the performance of an API? (HSBC)
What does immutable mean? (HSBC)
How do you make a class immutable (Barclays)
How do you fix an OutOfMemoryError? (HSBC)
Which strategy is best for avoiding Kafka partition rebalancing (Barclays)
What’s the difference between Heap and Stack Memory in java? (Barclays)
Java coding tasks for investment banks
Of course, you'll eventually have to put your money where your mouth is and prove your ability to code. Banks usually do this using platforms like CoderPad and asking questions similar to what's seen on Leetcode.
One of the most famous of these is Trapping Rain Water; research in 2023 showed this was the most common Leetcode task at Goldman sachs. This task has an acceptance rate of over 67%... there are harder alternatives.
Below are five questions asked at major US investment banks which each have an acceptance rate below 50%:
#239 - Sliding Window Maximum (Hard)
3.4 Million Submissions - 48.6% success rate
The sliding window function appears a tough concept to grasp, or at least master. You are given an array of integers and can see them only through a sliding door of size k, while only being able to see a finite number of integers at one time, it asks you to "return the max sliding window."
Where many appear to take issue with the question is the vagueness of it. Of course, in an interview the wording will likely be changed and you can't guarantee it will be easily understandable. The top comment says the goal is to show the maximum element from each window. This question is a good example of how simpler questions might be turned difficult by the way they are framed.
You can see the top ranked solution in Java here
#76 - Minimum Window Substring (Hard)
4.5 million submissions - 47.2% success rate
Another use of the sliding window, another question with a poor acceptance rate. This one differs in that here you are manipulating a string rather than an array.
You are given two strings of separate lengths and asks you to return the minimum window substring of one string so that each character of the second is present in it. As an example, if the first string were ADOBECODEBANC and the second were ABC, the answer would be BANC.
You can see one of the top ranked Java solutions here.
#79 - Word Search (Medium)
5.2 million submissions - 47% success rate
Proof that the hard tag doesn't necessarily encompass the hardest problems, Word Search has proved a tricky ask for the majority of coders. Operating more like Boggle than a traditional word search, the program checks if a word can be made by sequentially adding characters from the grid where each cell is horizontally or vertically adjacent.
These are some helpful diagrams for when the output is true vs when its false:
The key to standing out in this challenge is not just to make a solution that works, but one that can find the answer in a timely manner.
You can find the top voted solution in Java here.
#5 Longest Palindromic Substring (Medium)
12.3m million submissions - 37.5% success rate
One of the most difficult questions asked by banks is also one of the oldest on Leetcode. Longest palindromic substring asks that you search through a string of characters for palindromes, words that read the same front and back, and display the largest possible one that could be made.
For example, in BABAD, BAB (or ABA) is the longest palindrome. In RACECAR, the longest palindrome is... RACECAR
You can see the top ranked Java solution here.
#10 - Regular Expression Matching (Hard)
4.4 million submissions - 30.6% success rate
One of the hardest you're likely to come across is the dynamic programming challenge of regular expression matching. It asks that you run through a string with an input pattern to see if that pattern is matches. So, for example the string AA would not match the pattern A as it is not a complete match.
There are additional tags that complicate things however, if the pattern has a "." next to a character it asks that the string contain a single character of that type. If the pattern has a "*", it is asking that there be one or more of the character. For example, if we changed the pattern of the previous test from A to A*, the string AA would return a positive result now.
You can see the top ranked Java solution here.
Have a confidential story, tip, or comment you’d like to share? Contact: WhatsApp: http://wa.me/442079977910 (+44 20 7997 7910), Telegram: @AlexMcMurray, Signal: @AlexMcMurrayEFC.88 Click here to fill in our anonymous form, or email editortips@efinancialcareers.com.
Bear with us if you leave a comment at the bottom of this article: comments are moderated intermittently by human beings. Sometimes these humans might be asleep, or away from their desks, so it may take a while for your comment to appear. You must take sole responsibility for comments you post on this site. We will take reasonable steps to weed out anything that we consider to be offensive or inappropriate.