August 30, 2003
Java Interview Questions2
Just stumbled upon few of the Ranch posts I had participated in. At that time I was looking for some good interview questions on Java (unfortunately very few were available with answers) and thought why not start answering them. Unfortunately some of the threads did not proceed. I feel like I could revive these, any volunteer to help me in this. BTW the posts were here and here.
Thnaks for sharing your thoughts Brian 🙂
Off the top of my head, two of my favorite questions are:
1) How would you get the benefits of multiple inheritance in Java?
The usual answer is through interfaces which speaks to interface inheritance, but not implementation inheritance.
The answer I expect to hear is through composition and delegation although I’d accept mixins, introductions, etc. from the AOP world. That doesn’t happen too often though! 🙂
2) Is there anything you miss from C++?
The usual answer is a snarky, “No!” or “My programs don’t crash as much” or “pointers”.
One of a handful of answers I would like to hear:
1) templates
2) operator overloading
3) pointers (although this usually sparks a discussion)
Basically anything that suggests a non-trivial understanding of the good parts of the language that were left out for specific reasons.
My absolute favorite interview question not specifically related to Java is:
“What is the worst bug you’ve ever written?”
There is obviously a wide range of answers here. The ones to look out for:
“I don’t write bugs.”
“Uhm… I wrote this UI once and I got the label too far over.”
“Uhm… I had a memory leak once.”
What I look for is a sense of complexity in what they might have tackled, a sense of learning from their mistakes and an honest self-assessment about their potential for harm.
All of the best software engineers I’ve ever worked with have doozies that they just burst into laughter over when I ask it of them. I usually seed the discussion with mine:
“When I was newly out of college I was working on a message store and forward system on an AIX box for which we didn’t have the OS installation media (the box was a loaner from the Navy). I forgot to check the return value on a call which ultimately led to the complete disabling of the AIX box (due to other circumstances that aren’t worth explaining here). My manager had to lug that thing two hours across the state to reinstall the OS!”
Like any good Unix programmer, I learned from my mistake and “I’ll never do *THAT* again!”
🙂