I’d say this is better. It’s specific to Java and doesn’t require knowledge of one specific collection type. I’d say any candidate who can answer the ‘revised’ question would be able to use a HashMap if the situation required it. Plus, it lets you get a feel for how in-depth a person’s knowledge is. (similar to the pass by value/reference question)
I’d consider it more important for someone to understand how java collections are setup than someone to know “You can’t instantiate a map, but you can instantiate a HashMap”. Or that one is an interface and one is an implementation of that interface without knowing why an interface is used.
Of course, this is advice if you’re looking for a developer-type person…If you’re just looking for a code-monkey, then asking the question the other way is appropriate.
Might I suggest a question about testing? Find out whether or not the person considers tests important, and if they’ve used one of the xUnit (JUnit or otherwise) frameworks for writing them. I’ve run into some talented developers who don’t believe in unit testing, but the code they write is generally of a lower quality than someone who does test but isn’t as skilled. If your company doesn’t do any kind of automated testing then, while I’d question your sanity, this probably isn’t worth asking.
This isn’t really a java-specific thing, so it won’t help in figuring out if the candidate knows java, but it will speak to the quality of code you can expect if you hire them.
What’s the difference between a) call-by-name b) call-by-value c) call-by-need. Are these strategies interchangeable (i.e. would a program written in a programming language like Java have the same effects if any of these strategies was picked arbitrarily?).
Although now I see you’ve decided on your final questions :smack:
Guys, my apologies. I seem to be having trouble making myself clear in what I want. Some of you have provided good Java questions (my thanks to you!), but it seems like many of you think I want advice on how to interview.
I know in my heart that you mean well, so I suspect that I have not done my part and explained what I am looking for. I will try again and will try to be more thorough this time:
I am a programmer of 20 years and am well-versed in OO concepts and C/C++. I have been a hands-on manager for 7ish years and am still very active in programming.
I know how to interview. I will ask general programming questions and I will know if the candidate can program. I will ask general interview questions and will know what his time-keeping and other work habits are like. I do not need a general programmer who can learn Java. I have such people on my team. Heck, I will probably learn quite a bit of Java myself by the time this is over.
What I need is a language expert and I need him now. My timeline is such that the rest of my team will not be able to come up to speed quickly enough to acheive our goals. I normally do not manage this way and would normally push back hard on this type of timeline - but sometimes you must take what you are given.
I will have another person who knows Java help screen my candidate. However, this person does not work for me and will not be responsible if the project fails. I will be responsible for the failure of the project (and my team will be responsible for the success.) I want to get a sense of what the candidate knows about Java.
I am looking for some good questions about Java - not about programming I have those, not about time-keeping I have those. Questions about Java. It didn’t seem like a hard question when I asked it. If you were to ask me for questions about C++ I would provide 10 to 20 ranging from easy to hard rather quickly.
I appreciate the advice that has been given, but more, I appreciate those who have actually tried to answer the question that I am asking.
In that case, I’d think HashMap/Map question (or any other variant, like List vs. LinkedList) is fine. A Java language expert ought to be very familiar with the collections framework – it really is one of the core packages. Similar to the idea of the STL in C++.
If I wanted to make sure I was getting somebody who is not only good at Java, but also current, I’d ask a few questions that are specific to the Java 1.5.0 release (or as they call it, J2SDK 5.0), as that one came out about 2 1/2 years back. And Java 1.6.0 (J2SDK 6.0) was more recently released – although I don’t think that one had as many new things. I haven’t looked at it in detail yet, but I will be doing so shortly, since I’m teaching my advanced elective Java course again this summer.
As for the change from 1.4.2 to 1.5.0, that saw some language additions (e.g. generics, enhanced for-loops) as well as some important new classes in the API. For any environments that need to work at all with reading from standard input, or just general text parsing, the Scanner class was a major addition. They also added in the ability to do printf-style formatting (C coders ought to love that). The collections framework uses generics now. There were also some newer packages for dealing with multithreading.
This last one would fit in with your question “Describe synchronization in respect to multithreading.” Somebody who’s not done Java for a while might talk about the built-in monitors on objects, the keyword synchronized, methods wait() and notify() from the Object class. Somebody who is more up-to-date will probably talk about the java.util.concurrent package, how it has the Executor interface and features for building general thread pools which can help de-couple the management of threads from the actual Runnable tasks themselves. Also, java.util.concurrent.locks has a Lock interface, which can replace the use of synchronized methods. And it has Condition variables – a thread can block and then wait on a specific Condition, which gives a finer grain of control to managing concurrency (and using methods await() and signal(), on each Condition variable).
Here are a few questions that are specific to Java 1.5.0 additions:
What is the Scanner class? What can it be used for?
How are generics implemented in Java? What goes it mean to have an upper bound on a type parameter in a generic method?
What do the notations in the parameter list (the ? usage, along with ‘extends’ and ‘super’) mean in this method prototype? (Or perhaps just, “Explain the pieces of this method prototype”):
static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp)
I see. Ignore my comments about the hashmap/map question then. Someone who is claiming to be an expert on java ought to know the difference off the top of their head, or be able to deduce it from the two names.
I disagree. What I was trying to say before was:
The question will tell you if someone knows what a hashmap and a map are. It will not tell you if someone knows what the difference between an interface and a class are. If someone knows the second, there’s a good chance they’ll know the first, and if they don’t, they’ll know the first within seconds of looking at the javadocs for Map or HashMap.
If, however, they only know the difference between a HashMap and a Map (in temrs of how they use them/what keyword is used to declare each) and not the second, then there is a much smaller chance they’ll know the difference between some other interface and some other class.
Therefore, the answer to the difference between an interface and a class that implements that interface is of greater value than the simple answer to the difference between a Map and a HashMap.
OK, I see what you mean. I looked at the question as a vehicle for allowing the candidate to explain the difference between an Interface and a Class without asking the question outright – which I guess is what you’re advocating (ask outright.) I think it’s a question of interviewing style rather than of substance.
In any case, I think we agree that knowing the difference between an Interface and a Class is something even a basic-skills Java programmer must know!