Java Interview Questions – for Recruiters

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?
A:  Following are the methods:
1.      Clone
2.      Equals
3.      Finalize
4.      hashCode
5.      Notify
6.      NotifyAll
7.      toString
8.      wait
9.      getClass
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?
A: Finalize
Note to the Recruiter: If 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:
1.      public
2.      private
3.      protected
4.      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 a 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:
1. byte
2. short
3. int (also known as integer)
4. long
5. float
6. double
7. boolean
8. char
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:
1. Set
2. List
3. Map
4. Queue
5. Collection
6. ArrayList
7. LinkedList
8. TreeSet
9. HashMap
10. Hashtable
11. Arrays
12. Iterator
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:
1. I will writer a Java Util Timer Task. This task can wake up every 60 seconds and execute the job
2. 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)
3. 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 option he is good.
Q: What are the popular Java application servers that you know?
A: Following are widely used servers (in 2016):
1. Apache Tomcat
2. Jetty
3. IBM Webshpere
4. Weblogic
5. Resin
6. Glassfish
7. JBoss / Wildfly
8. Apache TomEE
Note to the Recruiter: Candidate has to answer atleast 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:
1.      Singleton
2.      Factory
3.      Builder
4.      Adapter
5.      Bridge
6.      Decorator
7.      Composite
8.      Visitor
9.      Proxy
10.     Memento
11.     Observer
12.     Command
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.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: