Morgan Stanley interview question

1. Difference between concurrent map and synchronized map ? No implementation details , just the difference 2. Volatile variables and synchornization 3. final classes 4. Callable and future and what they do. 5. Write a java program for finding out the first non repeating character in string. Example you have a string abcdeabc. Here the output must be d. Prepare this question, they will definitely ask you. 6. Read a file for a sequence of input string and print in in some order to output file. 7. You have a list of integers using an arraylist, find first if it contains duplicates, if doesn't contain duplicates, then return false else return true. Second part was to find that the duplicate elements. I am sure the interviewer might not be very sharp, however when you divide an array size by 2 , he was asking to round off an integer, which would be anyway a round off figure. I didn't understand what he wanted to prove , he is dumb or he is sharp !!!

Interview Answer

Anonymous

4 May 2020

Question 7, simply use a hashmap to maintain keep track of number of occurrences of integer. Key is integer and value is it's occurence count. Then traverse the map to check which key has value 2 or more.