Everyone has a favorite interview question. I have mine. I have never been asked this question on any software engineering job interview I have ever attended. However, I firmly believe this question tells more about a candidate than all the good old standbys (e.g. “reverse a linked list” and “write a thread-safe singleton”) do put together. So… ready?
Describe all the unit tests you would write for an implementation of java.util.List<E> or your platform’s equivalent. No need to write out the test code – just list the test cases.
That’s it! The interface being tested can vary from candidate to candidate. The important thing is that this question shows you how good the candidate is at proactively anticipating bad inputs, boundary conditions, and special cases. It is a truly universal and essential skill for all engineers, even those not fortunate enough to work in a test-driven environment.