0% found this document useful (0 votes)
5 views5 pages

JPMorgan Java Dev Interview Questions

The document outlines the interview experience for a Java Developer position at JPMorgan, detailing various technical questions and their answers. Key topics include Java 8 features, concurrency tools like CyclicBarrier and CountDownLatch, and data structures such as HashMap and LinkedList. The interview emphasizes the importance of strong fundamentals in Java, concurrency, collections, and SQL.

Uploaded by

Naveen BAYYA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

JPMorgan Java Dev Interview Questions

The document outlines the interview experience for a Java Developer position at JPMorgan, detailing various technical questions and their answers. Key topics include Java 8 features, concurrency tools like CyclicBarrier and CountDownLatch, and data structures such as HashMap and LinkedList. The interview emphasizes the importance of strong fundamentals in Java, concurrency, collections, and SQL.

Uploaded by

Naveen BAYYA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

📌 JPMorgan Interview Experience

– 6+ Years (Java Developer)


❓ Interview Questions & Answers


1. Write a program to remove empty and null strings from a String array
List<String> filteredList = Arrays.stream(arr)​
.filter(str -> str != null && !str.isEmpty())​
.collect(Collectors.toList());

✅ Uses Java 8 Streams to remove both null and empty strings.

2. Explain CyclicBarrier vs CountDownLatch

●​ CyclicBarrier: Waits for a fixed number of threads, reusable.​

●​ CountDownLatch: Waits until count reaches 0, one-time use.​

Use Cases:

●​ 🔁 CyclicBarrier – when threads must start together.​


●​ ✅ CountDownLatch – when main thread must wait for others to finish.​
3. What is CompletableFuture?

●​ Asynchronous, non-blocking, introduced in Java 8.​

●​ Supports chaining (thenApply, thenAccept), combining (thenCombine), and error


handling (exceptionally).​

Use Cases:

●​ Parallel execution, combining results, async APIs.​

4. Write a program to reverse an integer array without using inbuilt


functions
while (left < right) {​
int temp = arr[left];​
arr[left] = arr[right];​
arr[right] = temp;​
left++; right--;​
}

Time Complexity: O(n)​


Space Complexity: O(1)

5. What happens if we insert the same key in a HashMap?

●​ Existing value gets overwritten​

●​ put() returns previous value​

map.put(1, "Apple");​
map.put(1, "Cherry"); // Overwrites "Apple"

6. What is WeakHashMap?

●​ Keys stored as WeakReference​

●​ GC can remove entries if key is no longer strongly referenced​

Use Cases:

●​ Caching​

●​ Preventing memory leaks​

7. What is IdentityHashMap?

●​ Compares keys using == instead of equals()​

●​ Different references with same value = treated as different keys​

Use Cases:

●​ Object graph serialization​

●​ Reference-sensitive caching​
8. Find middle element of a LinkedList

●​ Use slow and fast pointer technique​

while (fast != null && fast.next != null) {​


slow = slow.next;​
fast = fast.next.next;​
}​
return slow.data;

Time Complexity: O(N)​


Space Complexity: O(1)

9. Rules for Instance Variables

●​ Declared inside class, outside methods​

●​ Can have access modifiers​

●​ Default values: 0, false, null​

●​ Not accessible from static methods directly​

10. Declare local variable in main() without initialization – what


happens?

❌ Compilation error
Reason: Local variables don’t get default values in Java.
11. Predict Output
List<Short> A = new ArrayList<>();​
for (short i = 0; i < 100; i++) {​
A.add(i);​
if (A.size() > 1) A.remove(A.size() - 1);​
}​
System.out.println(A); // Output: [0]

Explanation: Always adds then removes last element – list always contains just [0].

12. SQL Query: Employees per Department


SELECT d.dept_name, COUNT(e.emp_id) AS employee_count​
FROM Department d​
LEFT JOIN Employees e ON d.dept_id = e.dept_id​
GROUP BY d.dept_name;

💡 Final Thoughts
●​ This was Round 1 – focused on core Java, concurrency, collections, and SQL.​

●​ If your fundamentals are strong, you can clear it smoothly.​

You might also like