Published on 2016-05-10 by John Collins. Socials: YouTube - X - Spotify - Amazon Music - Apple Podcast |
In my day job as a development manager, I am frequently conducting technical interviews and phone screens with Java engineers. Very frequently these engineers are remote, so I need to be able to run through a rapid Q&A session with them before we go to the trouble of scheduling a second round involving the candidate traveling to our office.
The following list contains typical questions I ask, starting with some easier open questions to settle the candidates nerves, before digging deeper into their knowledge of Java and OO in general. The response flags indicate the kinds of flags I look out for in their answers.
Q1: Have you worked with NoSQL providers?
Response flags: Looking for level of knowledge/experience here. Knowledge of MongoDB, Riak, or Cassandra is good here.
Q2: What kinds of anti-patterns would you look out for during a code review?
Response flags: Code style minimum, non-functionals ideal.
Q3: What is a common anti-pattern that you have encountered, and how do you deal with it?
Response flags: Probing for design pattern knowledge and mitigation.
Q4: What is a useful design pattern that you have used? Give an example.
Response flags: Design pattern knowledge.
Q5: Explain the benefits of continuous integration.
Response flags: They should know what this is, and why do we do it. Should include unit testing.
Q6: What makes a good unit test?
Response flags: Unit test design approach, might include mocking, should include benefits.
Q7: In a relational database, what is the benefit of referential integrity?
Response flags: Should know what this is, cover foreign keys and indexes, and cascades. Normalization a plus.
Q8: What are some of the differences between a REST API and a SOAP API? Does REST offer benefits? Does SOAP offer benefits?
Response flags: Should explain what these two are, and highlight the main differences. REST benefits: closer to HTTP spec, stateless, JSON less verbose, pagination, multitude of light HTTP clients. SOAP benefits: WSDL describes service as contract, easier to mock service.
Q9: What kinds of indexes can you place on a database?
Response flags: Primary, foreign, and indexes are fine, deeper into index algorithms great!
Q10: Java is said to be a "strongly typed" language. What does that mean? What are the benefits?
Response flags: Explain what it means, compared to weakly/dynamically typed ideal. Benefits: type checking reduces type-related bugs, strong type validation, better performance versus dynamic typing.
Q11: Have you used Git? What are the advantages of using a distributed source control system?
Response flags: Should know what that is, and how it allows users to work completely offline for periods of time. Knowledge of index vs. local repo vs. remote repo.
Q12: Have you worked with feature branches? What are the advantages.
Response flags: Checking for branching best practices knowledge.
Q1: What is the difference between the JDK, JVM, and JRE?
Response flags: Checking for Java platform knowledge, should at least know the difference between a compiler and an interpreter (bytecode).
Q2: What is a JIT compiler? What benefits?
Response flags: Should know what this mean, and the benefits.
Q3: What is the classloader? What types of classloader are there?
Response flags: Checking for Java platform knowledge. Types: bootstrap, extension, system, plugins etc.
Q4: When would you use static methods or attributes? What are the dangers?
Response flags: When you have an attribute you want to share with all class instances, or methods that are invokable without a class instance. Need to be careful with threads.
Q5: What is the initial value of an object reference which is defined as an instance variable?
Response flags: Null.
Q6: What is a singleton, and how would you design one?
Response flags: Should explain what this is, and mention private constructor and public static method to return the same static instance each time.
Q7: What are the differences between an abstract class and an interface?
Response flags: Should explain what these are, basic OO knowledge.
Q8: What is the super-class of all Java classes?
Response flags: Object.
Q9: What is composition?
Response flags: Explain, ideally with a brief example.
Q10: What is method overloading?
Response flags: Same method, different params. Should explain benefits.
Q11: What are the differences between method overloading and method overriding?
Response flags: Should be able to explain with basic OO knowledge. Mention method access levels and final in parent for bonus points on overriding.
Q12: Describe a final variable, method, and class. Why would you use these?
Response flags: Can't change the value of final variable, can't override final method, can't inherit final class. Basic idea is to prevent overriding.
Q14: Can you use abstract and final both with the same method?
Response flags: No, explain why.
Q15: What is the meaning of immutable in terms of String?
Response flags: You can't change the value once it's set.
Q16: What is a Java package? What are the benefits?
Response flags: explain the benefits of namespaces.
Q17: What is difference between wait() and sleep() method?
Response flags: wait() - defined in Object class, releases lock. sleep() - defined in Thread class, doesn't release lock.
Q18: When should we interrupt a thread?
Response flags: if we want to break the wait or sleep state of the thread.
Q19: Can Java object be locked down for exclusive use by a given thread?
Response flags: Yes, using synchronized block. There be dragons...
Q20: What is a deadlock?
Response flags: Describe with example.
Q21: What are some of the benefits of a prepared statement?
Response flags: Pre-compiled by database therefore faster (no need to interpret), prevent SQL injection.
Q22: What is a persistent database connection? What are the benefits and risks?
Response flags: JDBC knowledge. Holds open connection therefore faster (no more handshake), but risk is that connections can become exhausted at database level.
Q23: What can you use to mitigate some of the risks of using persistent database connections?
Response flags: A database connection pool manager.
In my opinion an experienced Java engineer should be able to answer all of the above questions comfortably, getting >90% of them right. The open questions are designed to enable the candidate to show off should knowledge, as well as some enthusiasm for technology in general.