I had this interview with WS on 11 Jan 2020, and it seemed to be more kind of fomality as the interview was scheduled by them but they were not interested.
Any how then asked below questions including one question to code -
a) Tell me about yourself?
It is totally rubbish question when interviewer is also not interested to know as s/he has own set of questions to judge the
candidate. Such questions must be made illegal during the interviews.
b) Tell about the architecture, design & functional flow of your project?
This is asked like these people can understand anything from this explanation.
No, but they want to show their fake intellegence.
c) How do you review for the security of your code?
I believe that interviewers were not sure, as they were having something in their minds. Still I tried to ask about the context,
but these people were clueless. So anyhow, I told about the general coding practises where you try to make your objects
immutable & to safeguard the information there, including discouraging the overriding your class & methods.
d) If your junior has written the singleton class then what will you review there to make sure it is 'Singleton'?
I said that why to be oversmart if using jdk5+ version. Use 'Enum' directly rather showing too much useless intelligence to
implement your singleton.
e) Write the code to find the second largest odd number from the given list of numbers
Though many will try to use Streams here to show their updated knowledge. But if I test then usage of Streams may show
elegant code, but that elegance is not coming for free, so check it once before converting anything to Streams in the name
of Latest Trends. You can use Streams if you are getting Streams or you can parallelize your tasks in Stream or you need
lazy evaluation, else I will suggest to use the Imperative style, no matter what people say. Also using these new features
have a learning curve to understand the new APIs & change the mindset from imperative style to Functional style.
Any how then asked below questions including one question to code -
a) Tell me about yourself?
It is totally rubbish question when interviewer is also not interested to know as s/he has own set of questions to judge the
candidate. Such questions must be made illegal during the interviews.
b) Tell about the architecture, design & functional flow of your project?
This is asked like these people can understand anything from this explanation.
No, but they want to show their fake intellegence.
c) How do you review for the security of your code?
I believe that interviewers were not sure, as they were having something in their minds. Still I tried to ask about the context,
but these people were clueless. So anyhow, I told about the general coding practises where you try to make your objects
immutable & to safeguard the information there, including discouraging the overriding your class & methods.
d) If your junior has written the singleton class then what will you review there to make sure it is 'Singleton'?
I said that why to be oversmart if using jdk5+ version. Use 'Enum' directly rather showing too much useless intelligence to
implement your singleton.
e) Write the code to find the second largest odd number from the given list of numbers
Though many will try to use Streams here to show their updated knowledge. But if I test then usage of Streams may show
elegant code, but that elegance is not coming for free, so check it once before converting anything to Streams in the name
of Latest Trends. You can use Streams if you are getting Streams or you can parallelize your tasks in Stream or you need
lazy evaluation, else I will suggest to use the Imperative style, no matter what people say. Also using these new features
have a learning curve to understand the new APIs & change the mindset from imperative style to Functional style.
If you execute the above code for huge array of size '1000000000', then you will get below output. I had to comment-out the first stream usage where doing the sorting as it needs more memory to hold all the numbers in the memory. But still check the time taken by the Stream1 & normal iteration.
999999997
Time taken by stream1 : 1475ms
999999997
Time taken by loop : 784ms
If you parallelize the stream then you will see extensive improvement like shown in below result, but you should know if the tasks can be parallelized -
999999997
Time taken by stream1 : 604ms
999999997
Time taken by loop : 826ms
Still I am not sure about the consistent performance of Streams, so you better check it few times before using these. As I see imperative style gives pretty much consistent performance.
999999997
Time taken by stream1 : 1475ms
999999997
Time taken by loop : 784ms
If you parallelize the stream then you will see extensive improvement like shown in below result, but you should know if the tasks can be parallelized -
999999997
Time taken by stream1 : 604ms
999999997
Time taken by loop : 826ms
Still I am not sure about the consistent performance of Streams, so you better check it few times before using these. As I see imperative style gives pretty much consistent performance.