This interview was for the SDE-2 position. The recruiter contacted me via LinkedIn.com
Question was asked that was based on array data structures and one java oops related question.
1. Hash map vs Concurrent hash map
2. Internal implementation of hash map
5. Another data structure related question which I couldn’t remember
1. Explain project in detail
5. Fizz buzz printing
Write an efficient program which takes an input argument say n. Start from number 1 to n (inclusive) and if number is multiple of 3 then print “Fizz”, if number is multiple of 5 then print “Buzz”, if number is multiple of both 3 and 5 then print “FizzBuzz”. The interviewer was looking for code with just two ‘IF’ statements.
1. Usage of synchronize keyword
2. Find graph type from given coordinates
Here we are given 4 types of graphs and we have an API which takes co-ordinates say (x1, y1) and (x2, y2). Everytime the API is invoked it would return the next coordinate in the plane. We have to find the type of graph with minimum number of API invocation.
Graph Types were Strictly increasing line, Strictly decreasing line, Increasing then Decreasing plane and Decreasing and Increasing plane.
3. Explain Singleton design pattern
4. Explain Factory design pattern
This was a non technical round with only behavioral questions.
1. Dynamic Dispatcher
2. Atomic keyword and volatile keyword
3. Externalizable interface
4. Having a method definition inside an interface but java version is 1.7 hence default shouldn’t be used.
5. Usage of try with resource block
6. Difference between upcasting and downcasting and when we should use them.
7. Creating thread without using thread class and runnable interface
8. Shutdown hook
9. 5 features in Java 1.8 and 1.9
10. Executor Pool vs Thread Join Pool
11. There are 3 threads running independently how to ensure 1st thread runs more frequently
12. Different ways of applying lock on hash map
13. How hash set is implemented internally and question if hash set uses hash map internally or hash map uses hash set internally.
Round-7 (Hiring Manager)
Given a 2D array with 5 Rows and 3 Columns and a number n. Print all combinations of the array elements upto n. Example;
Array elements are;
a b c
d e f
g h i
j k l
m n o
If n is 2 then output should be: ad ae af bd be bf cd ce cf
If n is 3 then output should be: adg adh adi aeg aeh aei afg afh afi bdg … (and so on)
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course. In case you are prepared, test your skills using TCS, Wipro, Amazon and Microsoft Test Serieses.