Interview Questions - Technical

1. How to reverse an array

In place O(N) :  for() loop till middle of array and swap each element with element with same offset from end.
Convert to ArrayList, Collections.reverse, toArray
ArrayUtils.reverse ( Apache Library )

2.  Find all pairs which add up to k from an integer array.

3. Find the top 10 most popular words in a List of words.

4. How to share state between threads ?

5. How will you identify deadlock ?

6. What is busy spinning in multi-threading ?

Actively waiting by a thread for some condition to be true.

while ( !condition) {
    System.out.println("Condition still not true");
}

In busy spinning , thread is not relinquishing control of CPU and other resources like it does when you call wait() or sleep().  The only positive side of this is , if the conditions becomes true quickly , it will save time as it does not have to acquire the resources or repopulate cache etc. again as it already has those.

7. What is the significance of Future interface in multi-threading ?

8. 

Comments

Popular posts from this blog

SQL

Analytics

DBeaver