I attended a in-person interview recently and performed well. But surprisingly I got rejected. When I asked the HR for reason, he contacted the technical interviewer and told me that I was syntactically wrong while coding.
I used Google Guava for coding. So my code looked like this:
List<String> items = Lists.newArrayList()
instead of
List<String> items =new ArrayList<String>();
I know that the code will compile and work as expected.Is it ok to use third party libraries like Google Guava in interviews?
2
If you are doing something, non-standard at an interview – ask. Or at least say you are using Guava.
I do ask a simple Java question early in an interview. I usually tell candidates they can assume anything they want so long as they tell me what it is. In a simple question like this, if the candidate asked to use Guice, I’d probably say not to – just use core Java. I need to know candidates know core Java.
What happens if the interviewer doesn’t know the library you chose or it isn’t available at the company? (Not everything open source can be used at every company.)
Try to avoid being clever at interviews. Too many “Java developers” don’t know how to write Java. The interviewer has to assume incompetence before cleverness.
You say,
I know that the code will compile and work as expected.
… but as you’ve learned, it won’t… because you didn’t confirm that the correct version is available at build time, on the build machine(s).
That’s not the point though. The point, and the root cause of your not getting hired, is that you failed to communicate with the interviewer. You didn’t communicate a requirement or dependency for the code you were writing. Personally, I would consider that a large assumption (dependency management can be a pretty big deal that involves static analysis, code reviews, dev training, build, the installer/deployment, legal, SLAs, etc).
So now you know, and knowing is half the battle. But that doesn’t really help. What does is a big tip that I got when doing interviews:
For every line you write on the whiteboard, say something relevant.
Start with these as you’re writing each line:
- “I’m thinking that …”
- “This makes sense because… “
- “This assumes that… “
In your scenario, I would have said something along the lines of:
“I’m thinking that a simple list of strings should suffice, so I’ll just pull one out of Guava.”
… or even
“Is it safe to assume that the Guava libraries are available?”
As a point of interest, I write .NET/C# and I asked in an interview at Microsoft if it was safe to assume that I could use LINQ. The answer was no.
4
Would adding an import at the top help in showing what lib/class you are using?
import com.google.common.collect.Lists;
List<String> items = Lists.newArrayList();
1