Interview Questions
This week I helped perform 2nd-level interviews with some candidates for a position here at work. They all claimed to be good at Java.
Here are the questions I asked. (None of these questions were original. I found them various places on the web.)
- Write a class that represents a binary tree. A node in this tree holds only a single String value.
Write a method named ‘find’ that takes an argument of a String and returns a List of all the nodes whose value matches the argument. - If they had trouble with the previous question, I offered to let them answer this question: write code to count the on bits in a byte. Use any language.
- What does the “static” keyword mean in front of a variable? A method? A class? Curly braces {}?
- How many gas stations are in Rochester?
- A man needs to go through a train tunnel. He starts through the tunnel and when he gets 1/4 the way through the tunnel, He hears the train whistle behind him. You don’t know how far away the train is, or how fast it is going, (or how fast he is going). All you know is that (1) if the man turns around and runs back the way he came, he will just barely make it out of the tunnel alive before the train hits him and (2) if the man keeps running through the tunnel, he will also just barely make it out of the tunnel alive before the train hits him.
Assume the man runs the same speed whether he goes back to the start or continues on through the tunnel. Also assume that he accelerates to his top speed instantaneously. Assume the train misses him by an infinitesimal amount and all those other reasonable assumptions.
How fast is the train going compared to the man?
Of the three people we interviewed this week, not a single one could complete the binary tree code. Only one managed to create the class, but he couldn’t write the find method. They’ll probably hire him.
One of the tree-failures was able to write the bit counter code. I’m guessing his brain prefers to work procedurally.
The question about the static keyword tests a person’s depth of Java knowledge. I hate trivia questions in interviews, and that question was the closest I got. I don’t care whether you can remember specific API signatures, but you should understand the basic semantics of the language.
I was disappointed with the gas station answers I received. Everyone tried to guess based on how many gas stations were in their neighborhood. I should have picked a question that wouldn’t lend itself to that type of answer. Maybe next time I’ll ask how many tennis balls are in the air in the U.S. at this moment.
Nobody got the train question. Sigh.
3 Comments
- Jim replied:
Drop the gas station question. It’s one of those ridiculous pseudo-smart questions that really don’t offer any real insight into how a candidate really works or thinks. I would have answered: New York or Minnesota?
February 25th, 2005 at 4:24 pm. Permalink.
- Jeremy Stein replied:
Jim, you should leave your email address. It won’t be displayed, but it will allow me to give you the courtesy of a reply. Just in case you drop by here again, I’ll reply here…
I appreciate the comment. I actually have since decided that the question should be eliminated from my list. Although I think it did provide some insight into individuals to see how they answered, it’s not nearly as direct as asking someone to write code.
Also, I really hate getting asked pet questions that aren’t relevant to the job when I interview, so it’s rude for me to do it to others.
February 25th, 2005 at 4:29 pm. Permalink.
Stein Home
Family Notes
Poetry Corner
Jeremy's Journal