JP Morgan interview questions

308 questions from 60 interviews · updated from reports 2017-2024

Practise JP Morgan-style

About

J.P. Morgan is part of JPMorgan Chase, a financial services firm offering banking, payments, markets, asset management, and related services. In India, it hires for software engineer, software engineering intern, and other technology roles across applications, data, cloud, and security.

The roles that come up most are Software Engineer, Software Engineer Intern and Software Engineering Intern. This covers 60 candidate interviews reported from 2017 to 2024. The largest group sat it at internship level (28 of 56 that recorded a level). Among the 47 that recorded either route, arrivals split between campus drives (33, 70%) and off-campus applications (14, 30%). Most questions fall under DSA and CS fundamentals.

Category
Difficulty
Round

Interview questions

Q. Explain the Naive Bayes algorithm.

asked 2xmediumMachine learningTechnical2017-2023

Ans. Naive Bayes is a probabilistic classification algorithm that uses Bayes’ theorem to choose the class with the highest posterior probability for given features. It assumes features are conditionally independent given the class, which is often false but works well in practice, especially for text classification, spam detection, and simple high-dimensional datasets.

Q. Explain Support Vector Machines (SVM).

asked 2xmediumMachine learningTechnical2017-2023

Ans. Support Vector Machines are supervised learning models that classify data by finding the hyperplane that best separates classes with the largest margin. The key idea is that only the closest training points, called support vectors, determine the boundary. With kernels, SVMs can also handle non-linear separation by mapping data into higher-dimensional spaces.

Q. Describe something you learned from a recent mistake.

asked 2xeasyConflict resolutionHR2021

Ans. Pick a recent, low-risk mistake where you took ownership and improved your approach. Emphasise what happened, your role, the impact, and the specific change you made afterwards. Interviewers listen for honesty, self-awareness, accountability, and evidence that you learn without blaming others or overdramatising the failure.

Q. Explain the difference between an exception and an error in Java.

asked 2xeasyOOPTechnical2019-2020

Ans. An exception is a condition an application may handle, while an error is a serious problem usually outside the application’s control. Both extend Throwable. Exceptions include checked exceptions like IOException and unchecked ones like NullPointerException. Errors, such as OutOfMemoryError or StackOverflowError, normally indicate the program should not try to recover.

Q. Given a binary string, count the number of substrings that start and end with 1

asked 2xeasyStringsOnline test2021

Ans. Count the number of 1s in the string, say k, then the answer is k × (k − 1) / 2 for substrings using two distinct 1s as ends. Each valid substring is uniquely defined by choosing its starting and ending 1. If single-character substrings count, add k.

Q. Explain Machine Learning in very simple and intuitive terms so that a non-technical person can understand it.

asked 2xeasyMachine learningTechnical2023-2024

Ans. Machine learning is teaching a computer to learn patterns from examples instead of giving it exact step by step instructions. For example, if we show it many pictures labelled “cat” and “not cat”, it can learn what cats usually look like and then make a good guess on new pictures.

Q. Maximise Pair Count

asked 1xmediumArraysOnline test2024

Ans. Use a frequency map to greedily form each valid pair as soon as its complement is available. For each number x, check whether target minus x has unused count; if yes, decrement it and increase the pair count, otherwise store x. This maximises disjoint pairs in one pass, with O(n) time and O(n) space.

Q. Count Binary Substrings

asked 1xmediumStringsOnline test2021

Ans. Count binary substrings by grouping consecutive equal characters and adding the smaller length of each adjacent pair of groups. For example, runs of 0s and 1s with lengths 3 and 2 contribute 2 valid substrings. Use two counters for previous and current run lengths, so the scan is linear, O(n), with O(1) space.

Q. Detect a cycle in a graph.

asked 1xmediumGraphsTechnical2021

Ans. Use DFS to detect a cycle. For a directed graph, keep a visited set and a recursion stack; reaching a node already in the stack means a cycle. For an undirected graph, track the parent and ignore the edge back to it. Use an adjacency list. Time is O(V + E).

Q. Discover the nth prime number.

asked 1xmediumMathOnline test2023

Ans. Use the Sieve of Eratosthenes up to a safe upper bound, then return the nth number still marked prime. Store a boolean array for primality and cross out multiples of each prime from its square. For n greater than 1, an upper bound around n log n plus n log log n is sufficient. Time is O(limit log log limit).

Q. How does Gradient Boosting work?

asked 1xmediumMachine learningTechnical2020

Ans. Gradient Boosting builds a strong predictive model by adding many weak models, usually decision trees, one after another. Each new tree is trained to correct the errors of the current ensemble, often by fitting the negative gradient of a chosen loss function. A learning rate controls each tree’s contribution to reduce overfitting.

Q. Explain the B-Tree data structure.

asked 1xmediumData structuresTechnical2019

Ans. A B-Tree is a balanced multiway search tree where each node stores several sorted keys and has multiple children, with all leaves at the same depth. It keeps data ordered and supports search, insert and delete in logarithmic time. Its main value is reducing disk or cache accesses by storing many keys per node.

Q. Design a restaurant management system.

asked 1xmediumLow level designTechnical2019

Ans. Design it as modular services for reservations, table management, menu, orders, kitchen workflow, billing, payments and staff roles, backed by a relational database. The key detail is real-time state consistency: tables, orders and bills must use transactions or event-driven updates so hosts, waiters, kitchen and cashiers always see accurate status.

Q. Explain the DBSCAN clustering algorithm.

asked 1xmediumMachine learningTechnical2023

Ans. DBSCAN clusters points by density, grouping points that have enough neighbours within a radius and marking sparse points as noise. It uses two parameters: epsilon, the neighbourhood distance, and minPts, the minimum neighbours for a core point. Clusters grow from core points and include reachable border points, allowing arbitrary shapes.

Q. Solve the Josephus problem (modified variant).

asked 1xmediumRecursionOnline test2019

Ans. Use the Josephus recurrence and adjust indexing for the variant. For zero-based indexing, survivor J(n) = (J(n-1) + k) mod n, with J(1) = 0; convert to one-based if needed. Simulating with a circular linked list is O(nk), but the recurrence gives O(n) time and O(1) space.

Q. What are the new features introduced in HTML5?

asked 1xmediumWebTechnical2019

Ans. HTML5 introduced semantic elements, native audio and video, canvas and SVG support, improved forms, offline storage, geolocation, drag and drop, and new browser APIs. The most important change is that it made the web more application-friendly, reducing reliance on plugins like Flash and improving structure, accessibility, and multimedia support.

Q. What steps should you take to fix data biases?

asked 1xmediumMachine learningTechnical2023

Ans. Identify the bias, measure its effect across relevant groups, then improve the data by collecting missing examples, correcting labels, removing misleading features, or rebalancing and reweighting samples. The most important step is to test the model separately on each affected group, not only on overall accuracy, and monitor after deployment.

Q. Explain decorators in Python. How do they work?

asked 1xmediumPythonTechnical2021

Ans. Decorators in Python are functions that take another function or class and return a modified or wrapped version of it. The @decorator syntax is shorthand for reassigning the function to the decorator’s return value. They are commonly used for logging, authentication, caching, timing, validation, and keeping cross-cutting behaviour separate from core logic.

Q. How do you design a REST API to make it secure?

asked 1xmediumApi designTechnical2021

Ans. Design it with HTTPS everywhere, strong authentication, and authorisation checked on every request. The most important detail is to enforce access control server side, per resource, not just per endpoint. Also validate inputs, use short lived tokens, rate limit abusive clients, avoid leaking errors, log security events, and keep secrets out of code.

Q. Explain the K-Nearest Neighbors (KNN) algorithm.

asked 1xmediumMlTechnical2017

Ans. K-Nearest Neighbours is a supervised learning algorithm that predicts a new data point by finding the K closest training examples and using their labels or values. For classification it usually takes a majority vote, and for regression it averages. The key detail is that distance choice, feature scaling, and K strongly affect results.

Q. Job Sequencing Problem with Deadlines and Profits

asked 1xmediumGreedyOnline test2024

Ans. Schedule jobs by choosing the highest profit jobs that can still fit before their deadlines. Sort jobs by profit in descending order, then place each job in the latest free slot on or before its deadline. A disjoint set can find free slots efficiently. Time complexity is O(n log n) with union find.

Q. Calculate the square root of one billion mentally.

asked 1xmediumLogical reasoning2023

Ans. The square root of one billion is about 31,623. Write one billion as 1,000,000,000, or 10^9. The square root is 10^4.5, which is 10^4 times the square root of 10. Since square root of 10 is about 3.162, the answer is 31,620 approximately.

Q. Explain Support Vector Machines and soft-margin SVMs.

asked 1xmediumMachine learningTechnical2023

Ans. Support Vector Machines are supervised models that find the separating hyperplane with the largest margin between classes. Only the closest training points, called support vectors, determine this boundary. Soft-margin SVMs allow some misclassification using slack variables, controlled by a regularisation parameter, to handle noisy or non-linearly separable data better.

Q. Explain the Bellman-Ford algorithm and its use cases.

asked 1xmediumGraphsTechnical2019

Ans. Bellman-Ford finds shortest paths from one source to all vertices in a weighted graph, even when edges have negative weights. It repeatedly relaxes every edge for V minus 1 rounds, then does one more pass to detect negative weight cycles. It is useful in routing, arbitrage detection, and graphs where Dijkstra is unsafe.

Q. Merge overlapping intervals given a list of intervals

asked 1xmediumArraysOnline test2021

Ans. Sort the intervals by start time, then scan them once, keeping a result list of merged intervals. For each interval, compare its start with the end of the last interval in the result. If they overlap, extend the end; otherwise, append it. Time complexity is O(n log n) due to sorting, with O(n) space.

Q. What is the use of interceptors in Java applications?

asked 1xmediumFrameworksTechnical2021

Ans. Interceptors are used to run common logic before or after a method call, request, or response in a Java application. They are commonly used for authentication, logging, validation, transaction handling, auditing, and error handling. The key benefit is separating cross-cutting concerns from core business logic.

Q. Why does logistic regression require feature scaling?

asked 1xmediumMachine learningTechnical2023

Ans. Logistic regression needs feature scaling mainly so optimisation converges efficiently and reliably. If features have very different ranges, gradient descent takes uneven steps and may be slow or unstable. Scaling also matters with regularisation, because otherwise large-scale features are penalised differently from small-scale features, which can bias the learned coefficients.

Q. Explain the concept of regression in Machine Learning.

asked 1xmediumMachine learningTechnical2023

Ans. Regression is a supervised machine learning task where a model predicts a continuous numeric value from input features. Examples include predicting house prices, salaries, or temperature. The key idea is to learn the relationship between inputs and an output from labelled data, then minimise prediction error on unseen data.

Q. How many times should a fair dice be rolled to get a 3?

asked 1xmediumProbabilityTechnical2017

Ans. A fair die should be rolled 6 times on average to get a 3. This is a geometric probability problem: each roll has success probability 1/6, and the expected number of trials until the first success is 1 divided by p. So the expected rolls are 1 / (1/6) = 6.

Q. How can you perform asynchronous REST API calls in Java?

asked 1xmediumApi designTechnical2021

Ans. Use Java 11 HttpClient with sendAsync, which returns a CompletableFuture, or use Spring WebClient for reactive non-blocking calls. The key detail is to avoid blocking request threads while waiting for remote services. Configure timeouts, connection pooling, retries, and error handling, then compose results with CompletableFuture or reactive operators.

Q. Explain the working and internal structure of a hash map.

asked 1xmediumDBMSTechnical2023

Ans. A hash map stores key value pairs by applying a hash function to the key to choose an array bucket. Internally it is usually an array of buckets, each holding entries with key, value, and sometimes a next pointer. Collisions are handled by chaining or open addressing. Average lookup, insert, and delete are constant time.

Q. Explain basic graph data structures and their applications

asked 1xmediumGraphsTechnical2020

Ans. Graphs are usually stored as an adjacency list, adjacency matrix, or edge list, depending on the operations needed. Adjacency lists are space efficient for sparse graphs, matrices give constant time edge checks, and edge lists suit algorithms like Kruskal’s. Applications include maps, social networks, dependency graphs, routing, scheduling, and web links.

Q. Explain call and put options with an example or case study.

asked 1xmediumFinanceTechnical2023

Ans. A call option gives the buyer the right, not obligation, to buy an asset at a fixed strike price; a put gives the right to sell. For example, if a share is £100 and you buy a £110 call, you profit if it rises above £110 plus premium. A £90 put profits if it falls below £90 minus premium.

Q. Write a SQL query to delete duplicate records from a table.

asked 1xmediumSQLTechnical2017

Ans. Use a window function to number rows within each duplicate group, then delete rows whose number is greater than one. Partition by the columns that define a duplicate, order by a stable key such as the smallest id to keep. This uses a ranked result set, typically with O(n log n) sorting cost.

Q. Merge overlapping intervals given a collection of intervals.

asked 1xmediumArraysOnline test2021

Ans. Sort the intervals by start time, then scan them once, keeping a result list of merged intervals. For each interval, compare its start with the end of the last interval in the result. If they overlap, update the end to the maximum end. Otherwise, append it. Time complexity is O(n log n).

Q. Find the maximum sum k x k sub-matrix in a given n x n matrix

asked 1xmediumDynamic programmingOnline test2017

Ans. Use a 2D prefix sum matrix, then compute every k x k sub-matrix sum in constant time and keep the maximum. Build prefix sums in O(n²), where each cell stores the sum from the top-left to that cell. Then scan all possible top-left positions, giving O(n²) time and O(n²) space.

Q. How would you describe map-reduce programming to a developer?

asked 1xmediumDistributed systemsTechnical2023

Ans. Map-reduce is a programming model where you map input records into intermediate key-value pairs, then reduce all values for each key into a final result. The key detail is that map tasks are independent, so they can run in parallel across many machines before grouped data is reduced.

Q. Is multiple inheritance a good practice? If not, explain why.

asked 1xmediumOOPTechnical2017

Ans. Multiple inheritance of implementation is usually not considered good practice because it can make code harder to understand and maintain. The main issue is ambiguity, especially the diamond problem, where a class inherits the same method or state through multiple paths. Many languages prefer interfaces, composition, or mixins instead.

Q. Explain the difference between shallow copy and deep copy in C++.

asked 1xmediumOOPTechnical2021

Ans. A shallow copy copies an object’s member values as they are, while a deep copy also duplicates any owned dynamic resources those members point to. The key issue is ownership: with shallow copying, two objects may share the same pointer, causing double deletion or unintended changes unless copying is carefully controlled.

Q. Find whether there is a path between two given cells in a matrix.

asked 1xmediumGraphsOnline test2020

Ans. Use BFS or DFS from the source cell and try to reach the destination cell. Treat each valid cell as a graph node and move in four directions, ignoring blocked cells and already visited cells. Store visited cells in a boolean matrix. The time complexity is O(rows × columns), and the space complexity is the same.

Q. Given a collection of intervals, merge all overlapping intervals.

asked 1xmediumSortingOnline test2021

Ans. Sort the intervals by start time, then scan them once, keeping a result list of merged intervals. For each interval, compare its start with the end of the last interval in the result. If they overlap, extend that end; otherwise append it. Sorting dominates the cost, so time is O(n log n).

Q. How can you measure exactly 45 minutes using two identical wires?

asked 1xmediumLogical reasoningTechnical2019

Ans. Light wire A at both ends and wire B at one end. Wire A finishes in 30 minutes. At that instant, light the other end of wire B. Wire B has 30 minutes of burn time left from one end, so burning it from both ends uses that remainder in 15 minutes. Total: 45 minutes.

Q. Write a SQL query to find the second highest salary from a table.

asked 1xmediumSQLTechnical2019

Ans. Select the distinct salaries, sort them in descending order, skip the first row, and return the next one. This gives the second highest unique salary. The key detail is using distinct, otherwise duplicate top salaries can give the wrong result. The database typically uses sorting, so the time cost is about O(n log n).

Q. Explain deep learning and discuss CNN layers and their parameters.

asked 1xmediumMachine learningTechnical2023

Ans. Deep learning uses multi-layer neural networks to learn representations from data, with each layer extracting more abstract features. In CNNs, convolution layers use filters, kernel size, stride, padding and number of channels; activation layers add non-linearity; pooling reduces spatial size; batch normalisation stabilises training; fully connected layers perform final prediction.

Q. How does a priority queue work and what are its time complexities?

asked 1xmediumHeapTechnical2023

Ans. A priority queue stores items with priorities and always removes or returns the highest, or lowest, priority item first. It is commonly implemented with a binary heap, giving insert and remove-min or remove-max in O(log n), peek in O(1), and building from n items in O(n).

Q. Design appropriate class structures for a notepad-like application.

asked 1xmediumOOPSystem design2024

Ans. Use a Document class holding the text, metadata and dirty state, a TextBuffer for efficient edits, an EditorController for commands, and separate FileService and View classes for persistence and UI. The key detail is separating model, editing logic and presentation, so undo, save, search and formatting can evolve without coupling.

Q. Find the next permutation (next larger number) of a given sequence.

asked 1xmediumArraysOnline test2019

Ans. Find the first index from the right where a[i] < a[i+1], swap it with the smallest larger element to its right, then reverse the suffix. If no such index exists, the sequence is the largest permutation, so reverse the whole sequence. This works in place in O(n) time and O(1) space.

Q. How would you design a system to tally votes from election ballots?

asked 1xmediumProblem solvingSystem design2024

Ans. I would design an auditable pipeline where scanned or digital ballots are validated, anonymised, stored immutably, and tallied by deterministic counting jobs. The most important detail is verifiability: every accepted ballot should have a traceable audit record, duplicate prevention, clear rejection reasons, and independent recount support from the original immutable ballot store.

Q. Explain AVL tree and demonstrate insertion of elements from 1 to 10.

asked 1xmediumTreesTechnical2019

Ans. An AVL tree is a self-balancing binary search tree where each node’s left and right subtree heights differ by at most one. Inserting 1 to 10 in order triggers left rotations as the tree becomes right-heavy, giving final tree: root 4; left 2 with 1,3; right 8 with 6,9; 6 has 5,7; 9 has 10.

Q. Print a given matrix in spiral form (including non-square matrices).

asked 1xmediumArraysOnline test2019

Ans. Use four boundaries: top, bottom, left and right, and repeatedly print the top row, right column, bottom row and left column while shrinking those boundaries. After each side, check that the boundaries have not crossed, which handles non-square matrices. No extra data structure is needed. Time is O(rows × columns).

Q. What are profilers, and how can they be used or implemented in Java?

asked 1xmediumPerformanceTechnical2021

Ans. Profilers are tools that measure where a program spends time and memory, helping find bottlenecks, leaks, excessive allocation, and thread contention. In Java, you typically use Java Flight Recorder, VisualVM, async-profiler, or commercial tools. They work by sampling stack traces or instrumenting bytecode through agents such as JVMTI or java.lang.instrument.

Q. Explain deep learning concepts and parameters involved in CNN layers.

asked 1xmediumMachine learningTechnical2024

Ans. CNNs learn spatial features by applying shared filters over local regions, producing feature maps. Key parameters are number of filters, kernel size, stride, padding, input channels, weights and biases. Stride and padding control output size, while kernel size and depth affect receptive field and capacity. Activations add non-linearity, and pooling reduces spatial size.

Q. Given an array, sort it without using any built-in sorting functions.

asked 1xmediumSortingTechnical2019

Ans. Implement a standard sorting algorithm such as merge sort or quicksort and apply it directly to the array. Merge sort splits the array, sorts each half, then merges using a temporary array. It runs in O(n log n) time and uses O(n) extra space, giving predictable performance without built-in sorting.

Q. How do ridge regression and lasso regression differ from one another?

asked 1xmediumMachine learningTechnical2023

Ans. Ridge regression uses an L2 penalty, while lasso regression uses an L1 penalty. Ridge shrinks coefficients towards zero but usually keeps all features in the model. Lasso can shrink some coefficients exactly to zero, so it performs feature selection. Ridge is often better when many features have small effects.

Q. How do you handle exceptions thrown during the call of a constructor?

asked 1xmediumOOPTechnical2017

Ans. Handle constructor exceptions by wrapping the object creation in a try-catch block and treating the object as not created if construction fails. The key detail is that only fully constructed subobjects are cleaned up automatically, so constructors should use RAII or safe member objects to avoid leaking resources during partial construction.

Q. If a fair coin is flipped 10 times, what is the expected number of occurrences of "HH"?

asked 1xmediumProbabilityTechnical2021

Ans. The expected number is 2.25. Treat each adjacent pair of flips as a possible occurrence of “HH”. In 10 flips there are 9 adjacent pairs. Each pair has probability 1/4 of being HH. By linearity of expectation, the expected count is 9 × 1/4 = 9/4.

Q. You are given two hourglasses that measure 7 minutes and 4 minutes respectively. How can you measure exactly 9 minutes using them?

asked 1xmediumLogical reasoningTechnical2020

Ans. Start both hourglasses together. When the 4-minute glass empties at 4 minutes, turn it over. When the 7-minute glass empties at 7 minutes, turn it over. At 8 minutes, the 4-minute glass empties again; immediately turn the 7-minute glass over. It now has 1 minute of sand to run, ending at exactly 9 minutes.

Q. Given 10 bags of coins where one bag contains fake coins of different weight, how do you identify the fake bag using a weighing scale?

asked 1xmediumLogical reasoningTechnical2019

Ans. Number the bags 1 to 10. Take 1 coin from bag 1, 2 from bag 2, and so on, then weigh all 55 coins together. Compare the result with the expected weight if all were genuine. The difference, divided by the known weight difference per fake coin, gives the bag number.

Q. How would you explain a subject to a friend who is struggling to understand it?

asked 1xeasyCommunicationHR2024

Ans. A strong answer should describe a real time you helped someone learn, preferably under mild pressure. Emphasise patience, listening first, breaking the topic into simpler parts, using examples, and checking understanding. Interviewers listen for clear communication, empathy, adaptability, and whether you can explain without making the other person feel judged.

Q. How would you handle a situation where you are unable to communicate effectively?

asked 1xeasyCommunicationHR2024

Ans. Choose a real example where communication broke down because of ambiguity, audience mismatch, language, pressure, or remote working. Emphasise that you noticed the issue early, adapted your approach, checked understanding, used another channel, and followed up in writing. Interviewers listen for self-awareness, patience, ownership, and focus on the outcome.

Showing 60 of 308 questions. Ranked by how often the same question came back across interviews.

Practise a JP Morgan-style interview

A spoken interview built from these questions, scored when you finish; the feedback is yours.

Start practising

When you are ready, record The One: a single interview hiring teams watch, so you stop repeating first rounds.

Common questions

What questions does JP Morgan ask?

Candidate interviews most often cover DSA (39%) and CS fundamentals (38%).

How many rounds does JP Morgan interview have?

Candidate interviews show an average of 3.0 rounds per experience, with a typical sequence of Online test → Technical → Technical → HR. Individual interview paths can vary.

Is the JP Morgan interview hard?

Among questions with a recorded difficulty, the mix is easy 41%, medium 54%, hard 5%.