JP Morgan Interview | 602 - Senior Lead Engineer | April 2020
Summary
I interviewed for a Senior Lead Engineer position at JPMC in April 2020. The interview rounds covered data structures and algorithms, core Java collections, and advanced testing concepts.
Full Experience
I recently interviewed for a Senior Lead Engineer position at JPMC in April 2020. My interview experience was divided into several rounds, touching upon various technical aspects. The initial rounds focused heavily on fundamental data structures and algorithms, where I was challenged with a classic tree construction problem and implementing a generic stack from scratch. Subsequently, the interview delved into core Java concepts, including the characteristics and optimal use cases for different collections, their thread-safety properties, and specifics regarding ConcurrentHashMap and HashSet. Finally, there were questions about advanced testing methodologies using JUnit, particularly concerning how to test private methods and count method invocations for monitoring or verification.
Interview Questions (8)
Given the inorder traversal sequence: 4 8 2 5 1 6 3 7 and postorder traversal sequence: 8 4 5 2 6 7 3 1, construct the unique binary tree. Recall that inorder traversal follows LVR (Left, Visit, Right) and postorder traversal follows LRV (Left, Right, Visit).
Discuss which Java collection is best suited for scenarios characterized by a higher frequency of write operations and fewer read operations.
Identify a Java collection that not only maintains insertion order but is also efficient for write-heavy scenarios (less read, more write) and ensures thread-safety in a multi-threading environment.
Is ConcurrentHashMap synchronized and thread-safe?
Is HashSet thread-safe? Does it maintain insertion order?
Explain the approaches and considerations for writing test cases for private methods within a class using JUnit.
Describe how one can count the number of times a specific method is invoked, especially in scenarios where a delegator pattern is used. What techniques can be employed to achieve this for testing purposes?