Google questions…
While I told a few of my friends that I had been rejected by Google, I never publicly announced this fact. I think it’s a little unfair to my readers here, so, well, here you go, I got rejected. ;)
However, as the title implies, the main reason I’m posting up an entry is to share the questions that they posed to me to the wider public. Hopefully, someone somewhere will be able to find these useful. Good luck, whoever you are! :)
Note that these questions were asked in the context of the Java programming language and its standard libraries.
- How would you (unit?) test your networking code?
- What’s the difference between an array and an ArrayList?
- What’s the difference between a HashSet and an ArrayList?
- How would you implement a HashSet?
- How do you write write a good hashCode() function?
- What happens if hashCode() returns the same integer but invoking equals(Object) on the two objects returns false?
- You have a path object like ‘/home/remy/foo/./../bar’, how would you canonicalize it (as in, resolve /. and /.. properly)? So, the end result in this example would be ‘/home/remy/bar’. Can it be done in O(n) time?
- How would you test the above method?
- If an argument shouldn’t be null, should you throw a NullPointerException or an IllegalArgumentException? Note that the interviewer was only asking for my opinion.
- How does a Hashtable / HashMap work? How do they store their data? How fast can you get stuff out of it (with the get(Object) method)?