A good friend of mine is in the recruiting business. Some how he misjudged that I am good in Java :-).
He asked me to give a list of Java interview questions that he can use for preliminary screening, before he submits the candidate to the client :-). I am sharing what I shared with my friend.
Screening questions will vary based on the role/position/seniority of the engineer you are going to hire. Here is a general list of questions for junior – mid level Java engineers.
Q: Can you list some of the methods in java lang Object?
Note to the Recruiter: More methods they say, more marks should be given to them. Rarely anyone says 9. Even if someone says 3 out of 9 he is OK, don’t reject him. If he answers all 9 he is very good candidate (or he has read this blog).
Q: Before an object gets garbage collected, what method in the object will invoked?
Note to the Recruiter: If the candidate answers this question, he might be a good candidate.
Q: What are the different access specifiers in Java Language?
A: Following are the access specifiers:
- unspecified (or friendly)
Note to the Recruiter: Here candidate has to say all of the four. Sometime engineer might not know what the term “access specifier” means. In such circumstance, if he pauses for some time, hint him with one of the four answers.
Q: Can you list primitive data types in Java?
A: Here are the primitive data types in Java:
- int (also known as integer)
Note to the Recruiter: Here candidate should answer atleast 6 of them. Some of them would struggle or forget to tell “byte”, “short” and “char”.
Q: What is a ternary operator in Java? Have you used it?
A: Ternary operator is also known as the conditional operator. It can be used as an alternative to the Java if/then/else syntax.
Q: What are the primary interfaces and objects in java util package?
A: Following are some of the important interfaces/objects in java util package:
Note to the Recruiter: Even if candidate is able to say atleast 6 of them, he is OK. Don’t reject him.
Q: Say suppose you have to write a program that will execute a job on a periodic interval(say every 60 seconds), how will do program it in Java?
A: There are few types of answer to this question:I will writer a Java Util Timer Task. This task can wake up every 60 seconds and execute the job
- I will writer a Java Util Timer Task. This task can wake up every 60 seconds and execute the job.
- I will use a Quartz scheduler framwork. (Note to Recruiter: Quartz is just one of scheduler framework in Java, Other popular Job scheduler frameworks in Java are: Cron4j, jCrontab, Essiembre, OddJob, Fulcrum Scheduler, … Candidate can mention any one of them)
- I will write a thread, which will wake up every 60 seconds and execute the job.
Note to Recruiter: As long as candidate any one of the options he is good.
Q: What are the popular Java application servers that you know?
A: Following are widely used servers (in 2016):
- Apache Tomcat
- IBM Webshpere
- JBoss / Wildfly
- Apache TomEE
Note to the Recruiter: Candidate has to answer at least 5 of them.
Q: Can you tell some of the software design patterns that you have used or know about?
A: Some of the popular design patterns are listed below:
Note to the Recruiter: This question is for a mid to senior level developers. Candidates with mid-level experience should be able to answer atleast 3 of them. Senior level candidates should be able to answer more of them.
Q: What is the difference between JDK, JRE and JVM?
Runtime Environment (JRE) contains only tools/libraries that are required to run Java application.
Java Development Kit (JDK) contains all tools/libraries required to build and run Java application. Basically JDK is the superset of JRE.
Both JDK and JRE contains JVM
Java virtual machine (JVM) is an abstract computing machine that enables a computer to run a Java program. In simplified words JVM is where java programs are executed.
Note to the Recruiter: This is a tricky question. Even experienced candidate may not get it right. If any candidate answers this question correctly, he might be a star
One final note to the recruiter: More than the answers to the question, asses rate (or speed) and confidence with which engineer answers these questions. It makes a huge difference. It differentiates real candidates. If someone answers the questions quickly and with confidence, then he is a very thorough with the subject, give him a high priority, over a candidate who takes long time to respond to the question.