Does anyone have a good interview question to ask prospective junior java developers? They will have a two year minimum experience requirement. The questions will be on a written test and they will have five to ten minutes to answer each question.
Limit to one interview question per response for voting purposes please.
Compare and contrast (don't you love that phrase?) the modifiers public, private, protected and default.
ReplyDeleteCompare an interface to an abstract class and give an example of when you might use one of each.
What does the modifier final mean to a class and a variable?
What is overloading and why might you use it?
What is garbage collection and how does it work in java?
How do you make a Thread in java?
Write a generic main method and explain what each item in the method signature means.
Explain how try/catch/throw/finally work.
What is an Iterator and how do you use it?
What are generics?
Are these lines of code valid and describe why or why not:
List<Object> myList = new ArrayList<String>(); \\(hint: no)
Map<Integer> myMap = new HashMap<int>(); \\ (hint: also no)
Avoid you-know-it-or-you-don't questions about the Java API. These are worthless, IMO. My favourites are questions that ask for value judgements, because they allow good candidates to show their insight without necessarily having to have gained familiarity with particular parts of the API (which is what Javadoc is for, after all...)
ReplyDeleteMy favoured technical question is to get the interviewee to implement the equals method for a simple class with a couple of fields, and in the case of a face-to-face interview to defend their implementation (which will pretty much always be non-optimal or missing something).
Other questions I'd consider at least sprinkling into the list would include things like: "What feature would you most like to see added to Java?", "How would you go about debugging a NullPointerException?", "In a twenty-lecture training course on Java, in which lecture should the concept of object orientation be introduced, and why?", "How does Java differ from other programming languages you've worked with?", and general language-agnostic questions like "Why are patterns a good thing?", "Should good code be self-documenting, or is it the responsibility of the developer to document it?", and the suchlike. Mostly I'm not looking for a right answer as such with a lot of these questions. I'm looking for an understanding of the question, a coherent chain of thought behind it, the ability of the interviewee to defend their viewpoint, and the ability to go beyond the simple multiple choice API questions that got them their JCP qualification that's no doubt taking pride of place on their CV.
They can learn the parameters to String#regionMatches later, or just let their IDE provide the list every time for all I care.
You attempt to run a bunch of compiled Java code that someone else gave you, and you see the following near the start of a stack trace:
ReplyDeleteNoClassDefFoundError: org.apache.commons.lang.StringUtils.
What went wrong? How can you fix it?
Have them write code!
ReplyDeleteFizzbuzz is a good quick test...
http://www.geekschool.org/programming/fizzbuzz/
Ask them to do OOAD of a given system description in 10 minutes. Observe how they tackle the problem.
ReplyDeleteWrite some Java code with obvious errors. Inside the code you place
ReplyDeleteinnocently a '==' comparison of objects instead the correct '.equals()'.
(Be sure that the compared objects in memory are different and the
code fails, else the candidate may claim optimization).
If you haven't programmed in Java a while (especially if you come
from C/C++ !) you simply don't see the error ! It is a warning sign
if someone claims long experience and can't detect this error because
it is a real pain in the ass when you learn Java.
Ask what is the difference between an ArrayList and a Vector, a HashMap and a HashSet.
ReplyDeleteI believe that more important than pure technical knowledge is the ability to communicate complex technical issues to someone who doesn't have a technical background. It's much, much easier to teach specific programming skills to someone who communicates very well than to teach communication to a pure techie.
ReplyDeleteTo that end, my favorite question is: "Pretend that I am your grandmother (or other non-technical person). Explain to me what it means for a program to be object oriented."
Remember--this is all about communication. Ask your technical questions too, but teaching communication is much more difficult than teaching programming.
Ask, how hashtable works.
ReplyDeleteAsk when will the finally block not get called?
ReplyDelete