Wednesday, 4 December 2013

Cracking technical interview in Java

This is not the silver bullet to crack interviews, but what I am trying to bring out is to showcase how and when you need to choose what is best for a particular interview session.
 
Also please do not assume the answers here would help you get to the next dream job, but definitely some tricks and the way you present your answers will bring you some steps closer to crack technical rounds of interview.
 
In the very recent times I have happen to compare my past interview experiences and based on that I could say there are two kinds of candidates:
  1. Who prepare themselves for the interviews
  2. Use right kind of experience and knowledge for the interviews
Below is what I feel are some subtle differences between the above two:
  1. You would agree that working and sustaining self on the Java platform has always been a challenging thing due to the availability of wide spectrum of frameworks and the learning curve associated with them. Given this fact are you 100% confident that you can learn all of those and still you have 90% chances of clearing the interview? Think about it.

    Lets add more complexity here. Primarily banking and product based companies they look for people also good in Data structures, Algorithms, OS concepts, Design patterns, etc. Now what are your chances? I have experienced that banking and product based companies primarily ask questions related to DS and algorithms a lot and most of us like me are not able to answer after certain level of depth. So your chances are reduced to 50%.

    How about your confidence level once you are done with such kind of interview? Do you feel motivated or confident to try some other company?
     
  2. On the other hand, smart answers and managing with the high level knowledge of things may work out for you. NOTE I used “may”. I will be answering HOW part in the next few paragraphs.
At the time of writing this blog, I am at 9-10yrs of experience. I have appeared for interviews for service based to banks to product based companies. So below what I am presenting is only reflection of my views and experiences.

TIP# 1: Be confident and always assume that interviewer does not know more than you.

TIP# 2: Try to be the controller for the interview.

TIP# 3: Try to get hold of White board during discussions

TIP# 4: Be positive in your replies to questions, even if you don’t have answer to the question.

Below I would demonstrate some questions with answers from my experience which have actually worked and I have succeeded also.
 
Q# 1. Explain the architecture of your current project.
(Such questions opens an opportunity for you to control the interviewer in whatever direction you want to. So if you are best in collections or multi-threading or performance tuning or whatever, try to use all hints in your explanation. Interviewer would definitely ask you more questions around it. Make effective use of White board (if available), interviewers not only want to test your technical ability but also how effectively you can communicate in the team or with client depending on the role interviewer is looking for.)
 
Q# 2. What is ThreadExecutor and when to use it?
(Assuming that you have some exposure to multi-threading, but you may not have used concurrency package in any of your projects.)

Ans. I have worked on multi-threading, but my application was a maintenance project. So I did not got any chance to apply the usage of this class. But to answer your question, this feature was introduced in Java 1.5 and is primarily used for thread pools. It helps the programmer by abstracting the complexity of managing the thread pool.
(This may not be the actual answer interviewer would have been expecting from you, but you would set the impression right by not giving a straight forward NO as answer.)

Q# 3. Have you worked on Hibernate?
(Assuming Hibernate is not in your resume but still interviewer asks you this question. Here the intention of the interviewer is not to demotivate or harass you, but interviewer wants to understand if you are willing to learn something new along with your day to day work. So NEVER answer it as NO.)

Ans. If you see none of my projects involved that complexity which would trigger the need for using Hibernate. Moreover it was a technical decision which technology suits our client, so they can also easily maintain the application later.

It was not by choice, but unfortunately or fortunately I did not get to learn it, but if I get to work on any suitable project where Hibernate seems useful, then why not. I can learn and will like to work on it.
 
Now lets look at some of the questions I have faced during interviews:
  1. What is Serializable? Which class is responsible for it? (Click here!!!)
     
  2. If parent class is serializable, how would you make child class non-serializable? (Click here!!!)
     
  3. How to make singleton class as thread-safe? (Click here!!!)
     
  4. When do you use comparable and comparator?
     
  5. What is the difference between singleton and prototype scope in Spring? (Click here!!!)
     
  6. How to make beans with singleton and prototype scope as thread-safe? (Click here!!!)
     
  7. How is singleton in Spring different from a singleton class? (Click here!!!)
     
  8. What is difference between bean factory and application context in Spring?
     
  9. How would you display 1 million records using pagination on a webpage? (Considering limited memory and lot of network calls can cause performance issues.)
     
  10. How would you stop a user from clicking anywhere on the webpage, other than the operations that are desired? (e.g. you have a functionality which spreads across pages. User clicks on page 1, then on page 2, then on page 3 to complete one operation.)
     
  11. If your application needs to undergo maintenance, what are the possible ways of displaying the error page “Under maintenance” to the user? (without any change to application ear or war)
     
  12. How would you define structure of a node in a single linked list using Java (can’t use collections)?
     
  13. How would you detect and remove loop in a single linked list in a single pass? (w.r.t to Data structures)
     
  14. How would you access the second last element in a linked list having N nodes in a single pass? (w.r.t to Data structures)
     
  15. How does HashMap work?
     
  16. What is the purpose of equals & hashcode with reference to HashMap?
The answers are just a google away. Anyways I would soon be publishing the answers as well.

I welcome any suggestions and similar experiences and would definitely look forward to accommodate them in this blog..

No comments:

Post a Comment