Why is “main” static?
Recursive problems are also good, as loads of people cannot manage them.
What’s the difference between an object and a class?
Why is “main” static?
Recursive problems are also good, as loads of people cannot manage them.
What’s the difference between an object and a class?
Java: East of Krakatoa?
I’m a Java hobbyist, not a professional programmer - but an object is an instance of a class.
Right? Do I get the job?
I think a big part of knowing a language is knowing the libraries. I’d get a feel for their knowledge of the standard Java libraries and some of the larger 3rd-party libraries; try to gauge the breadth and depth. Which libraries to focus on depends a bit on the position’s level as well as what qualifications you are trying to fill. A nice side-effect of these questions is that you don’t need to be a Java guru to ask credible questions.
Some examples: For a junior position, as about the collection classes, what are the differences, when would you choose one vesus the other. If you do multi-threads, ask about the concurrency classes, why are they needed, what problems do they solve. If you do a lot of XML, ask them which XML implementation they have used, have they used xmlbeans, castor, JDO, JAXB, and even if not, what do these technologies solve. If they claim to be an expert with a library, ask them what some of the weaknesses of the library are. You can ask them what some of the Jakarta libraries are and which ones have they used.
If you decide to go with asking esoteric language questions, I suggest putting together 3-5 questions in increasing difficulty. Let the candidate work through them easiest to hardest and see how far they get. If you want, you can put their mind to rest beforehand that you are going to ask increasingly difficult questions and not to worry about eventually getting one wrong.
I ask them to describe their current project at their current job. It’s something they ought to be intimately familiar with. Real quickly it becomes apparent if they’re code monkeys who can be relied upon to get string property gets/sets coded correctly most of the time, or if they really can think & understand the bigger picture.
I agree with the poster above who suggested having teh cadidate write a trivial recursive function. We use recursion every day processing tree structures & if recursion baffles an applicant it’s all over. Bugs I can deal with, but bafflement is a dead-end.
Something else to consider … http://www.codinghorror.com/blog/archives/000781.html
One is horrified.
A friend of mine was given a coding assignment and told to bring it in and demo as part of his interview. That pretty much separates the coders from the talkers.
Since you seem to be looking at “how does he think”, having him analyze a small program also sounds like a good test (just ask “what does it do?”; given how many people would insist in interpreting that as “find the bug”, giving him an unbugged program may count extra). Given the amount of cursing I hear from the programmers whenever they need to modify some other guy’s job, that is… even if you’re not officially an “analyst/programmer”, you need to be able to read other guy’s code.
This reminds me of a C++ programming candidate we had in once who followed up his technical interview (which went fairly well) by emailing us, unprompted and completely on his own, the executable for a toy program he had written (with a GUI) that graphically showed various statistical info about an input numerical data time series, along with the source code for it (bar chart, dispersion, scatter/plot line, etc.).
The app was reasonably slick and functional.
The code was rife with GOTO jumps used for error handling and loop termination conditions, inscrutable variable names like “a”, “b” and “val1” or “val2”, and seemingly random indentation. It wasn’t a case of incompatible tab stop settings between TextPad and vi or Emacs or something, at least not as submitted. It seemed possible that he had an indentation convention used to denote level of confidence in the code, i.e., his (mostly commented out) print statements for debugging were fully left justified, newer code was slightly indented, and the most stable seeming code deeply indented (regardless of looping level).
The GOTO statements were particularly ironic in that part of his technical interview included questions about C++ error handling, and he was familiar with try, throw and catch concepts and could give sample code on paper illustrating their use. We had also mentioned during his interview that we expect “good citizenship” from our programmers, being as we have a very large code base, and he had expressed relief at finally working with other disciplined coders (suggesting that he had been a voice crying in the wilderness at his current job with respect to coding standards and practices).
We wondered if maybe he sent in a cribbed sample app from someone or somewhere else, but (a) why do that unasked for, and (b) wouldn’t he at least read what he was sending first?
Well, technically speaking (terminology-wise), an inner class is a non-static nested class. However, nested classes can also be static – they’re just not officially called “inner” classes.
My guess as to why – the term “inner” could be interpreted to imply that the class is inside an object, and that’s only possible if it’s not static. (A static nested class is only usable from a static context).
That kind of depends on what the focus is – what the interview is trying to discover.
Are you trying to discover how much Java-specific knowledge the applicant has? Or how much programming experience in general? Or broader knowledge of useful Java libraries (like the collections framework, commonly used classes like String and StringBuffer, GUI components, etc)? Understanding of Java as opposed to other languages, like C++?
I’d probably set the questions differently depending on the main focus.
Some Java language-specific questions (not library specific):
What’s the difference between an interface construct and an abstract class?
What’s the difference between a checked exception (aka normal exception) and an unchecked exception (runtime exception)?
What does it mean to declare a class with the keyword final? What about declaring a method as final?
Answers:
An abstract class can contain abstract methods as well as normal methods (and all sorts of data). An interface construct can only contain constant data, method signatures (which are essentially abstract methods, no definitions), and nested types.
A method must either handle a checked exception internally, or it must “claim” the exception (i.e. specify, with the keyword throws, that it can throw the exception back to the caller) – else the compiler complains. There’s no such compiler restriction on a runtime (unchecked) exception.
A final class cannot be extended (i.e. subclassed). A final method cannot be overridden in a subclass.
OK, 200 dollars on books and a weekend of reading them later, here is what I have decided on. It is my belief that any moderately experienced Java developer should be able to answer most of these questions. As mentioned earlier, I already have a list of programming questions and a list of general interview questions, so this rounds out my interview.
What is the difference between an Interface and an Abstract class?
What is the purpose of garbage collection in Java, and when is it used?
Describe synchronization in respect to multithreading.
Discuss pass by reference and pass by value.
What is the difference between HashMap and Map?
What is the difference between Swing and Awt?
What is the difference between a constructor and a method?
What is an Iterator?
What is static in java?
How do you declare a global variable in JAVA?
How would you create a class that can only be instantiated once?
Will the finally always execute in a try/finally block?
Strictly speaking, Java only has one type of parameter passing – pass by value. It’s just that all objects and arrays in Java are accessed through reference variables. When a reference variable is passed into a function, it is passed by value. Meaning a copy of that reference variable is made (but both of them refer to the same physical object in memory).
So this effectively acts like C++ pass-by-reference (same kind of call syntax).
Just pointing this out, because if somebody answers this question with “Java only has pass-by-value”, they aren’t wrong. (Although they should be able to explain what I wrote above).
Or, to re-state the above in a way most Java programmers have probably heard: “It isn’t true that Java has no pointers; rather, all Java has is pointers!” (well, and the “primitive” non-object types… e.g. int. But I digress)
Thanks for the head’s up!
Actually, I phrased it this way to see what the answer would be. I would expect a “coder” to answer “Java only has pass-by-value” but would expect someone who understands the language a little better to give an answer more like what you did. If I get “Java only has pass-by-value” I will ask if he/she can expand on the answer a little.
In your OP you said that there are going to be Java gurus on the interview panel. So don’t step on their toes. Let them ask the technical questions, though you might want to go through what they’re going to ask beforehand. You’re the manager, right? So ask about documentation, timekeeping, working as a member of the team, requirements analysis, what the customer wants vs what he requests, and so forth.
I’d stay away from this one…it’s too much of a “have you memorized the standard library” type question. I used to do quite a bit of java programming (a few years ago), and I’ve forgotten the difference by now. However, I’d be able to figure it after looking at the standard api for about 5 seconds.
The rest of the questions, however, sound like a good mix between java specific and general programming knowledge.
Maybe you are right - how about I replace that question with Monstre’s excellent:
Ask something practical, and open-ended; as others have said, you really want to see how they think. I have had good luck with the following:
Suppose that you have two threads (call them A and B for simplicity). Thread A needs to perform some task (taskA), but only after thread B has performed taskB. How can that be accomplished?
Then just let the interviewee talk (and possibly write). You’ll quickly find out if they really understand threads, and how the wait/notify mechanism works, and whether they understand synchronization, etc… Or maybe that they’re an expert on semaphores or something.
Again, I’d have to gauge what questions I’d ask based on what the job position is really looking for. You said:
Are you specifically looking for somebody who is already well-versed in Java? Or are you looking for a good progammer, who will be needing to use Java for this particular job position?
The two are not quite the same thing. For instance, somebody who is already a good coder in C++ and really understands the concepts and details would be able to learn Java quickly – despite not knowing all the libaries inside and out. If this is the case, I’d stick to more general programming questions – perhaps ones that are specifically object-oriented, if the job is looking for somebody with OOP experience.
If the job is for somebody who’s already well-versed in Java (or if the preference would go to such a person), then the Java-specific questions would apply here. Although I wouldn’t rule out a good progammer just because they still have to pick up this language’s syntax.
I’m guessing that the intent of this one was to show whether the interviewee understands the difference between the interfaces and the implementations in the collections framework (or in any similar sort of library set). There are other examples that serve the same purpose – like the List interface vs. the LinkedList implementation of List. (Just like HashMap is an implementation of the Map interface).
Another possible approach – if knowledge of Java collection data structures is desired – just ask the interviewee to describe their understanding of the general set-up behind the collections framework (interfaces, implementations, algorithms).