Interview Process For Java Developers
Interview Process For Java Developers
Table of Contents
1 INTERVIEW PROCESS...............................................................................................................2
1.1 Technical Interview – Structure..............................................................................................2
1.1.1 Review the Professional Background of the Candidate.......................................................2
1.1.2 Warm Up.............................................................................................................................2
1.1.3 Java Language Knowledge...................................................................................................3
1.1.4 Java Framework Knowledge................................................................................................3
1.1.5 Data Structure and Logic Questions....................................................................................3
1.1.6 Design.................................................................................................................................4
APPENDIX A – BASIC JAVA QUESTIONS..............................................................................................5
APPENDIX B – BASIC JAVA FRAMEWORK QUESTIONS........................................................................7
Hibernate..............................................................................................................................................7
Spring 7
APPENDIX C – DATA STRUCTURES, LOGIC & ALGORITHMS...............................................................10
Immutable..........................................................................................................................................10
Reverse a Stack...................................................................................................................................11
Throttling Problem..............................................................................................................................12
Cache Problem....................................................................................................................................12
APPENDIX D – SIMPLE DESIGN QUESTIONS......................................................................................14
Chess Game........................................................................................................................................14
Page
Java Developer – Interview Process
1 Interview Process
This section focuses on the technical part of the interview. The interviewer must review the
candidate’s CV before the interview and understand the reasons for searching for a new position.
At any point if you are sure that the candidate does not fit then there is no point in continue the
interview.
i. Objective:
- Understand what was the candidate role and responsibilities
- What the candidate did by himself and to what exactly the candidate was responsible
- How well the candidate is familiar with the product, implementation and overall
architecture
iii. Expectations:
- Clearly explain the system and its main modules
- Clearly explain what the product/system does
- Organized
- Knows the details and familiar with design decisions (if not a junior)
- Can describe what the candidate would have done differently and why
1.1.2 Warm Up
i. Objective:
- Free style questions what meant to understand how the candidate react to stuff the
candidate is not familiar
i. Objective:
- Verify the candidate has a good knowledge in the Java language and the way Java
program is running
iii. Expectations
- Correct answer to most questions
i. Objective:
- Verify the candidate has a good knowledge in common Java framework, how they
are used and why, benefit from using them etc. Usually candidates declare that they
are familiar with in their CV.
iii. Expectations
- Good understanding of framework the candidate used
- Good candidates know how the framework is implemented and what are the
advanced features
- Average candidates knows only basic features and have difficulties to explain and
describe the benefit, design etc
i. Objective:
- See that the candidate can think of effect solutions to data structure related problems
- Basic algorithm understanding
- Knows how to evaluate the complexity of the solution the candidate provided
- Understand hints and use them for improving a non-efficient algorithm
- The questions in this section should be structure in a way that is fairly simple to find
a non-efficient solution and then it gets complex to reach the effect one. The
candidate will likely need assistance to reach the best solution.
- Using a few questions from Appendix C – Data structure & Algorithm questions
iii. Expectations
- Exceptional candidates reach the best solution without help
- Good ones find the simple solution quickly and then with some assistance reach the
desired solution
- Below average either can’t pass the simple solution
1.1.6 Design
i. Objective:
- Check the candidate ability to do a quick design to a problem
- Good separation to classed
- Good isolation of logic to component
- Reuse when possible
- Main flows are easily described using the created classes and their APIs
iii. Expectations
- Good design with clear separation to classes and clear isolation and boundaries
- Easily adopt to changes
- Efficient
Unchecked exceptions are RuntimeException and any of its subclasses. Class Error and its
subclasses also are unchecked. With an unchecked exception, however, the compiler doesn't
force client programmers either to catch the exception or declare it in a throws clause. In fact,
client programmers may not even know that the exception could be thrown. Example:
StringIndexOutOfBoundsException thrown by String's charAt() method• Checked exceptions
must be caught at compile time. Runtime exceptions do not need to be. Errors often cannot be.
Usually, when you only care about running Java programs on your browser or computer you will
only install JRE. It's all you need. On the other hand, if you are planning to do some Java
programming, you will also need JDK.
Sometimes, even though you are not planning to do any Java Development on a computer, you
still need the JDK installed. For example, if you are deploying a WebApp with JSP, you are
technically justrunning Java Programs inside the application server. Why would you need JDK
then? Because application server will convert JSP into Servlets and use JDK to compile the
servlets. I am sure there might be more examples.
Isolate different applications running within the same JVM (ensuring they don't interfere with
each other, e.g. through static variables)
Hibernate
1. What is OR Mapping?
Object-relational mapping (ORM) is a mechanism that makes it possible to address, access and
manipulate objects without having to consider how those objects relate to their data sources.
ORM lets programmers maintain a consistent view of objects over time, even as the sources that
deliver them, the sinks that receive them and the applications that access them change.
Based on abstraction, ORM manages the mapping details between a set of objects and
underlying relational databases, XML repositories or other data sources and sinks, while
simultaneously hiding the often changing details of related interfaces from developers and the
code they create.
2. What is HQL?
Hibernate Query Language (HQL) is an object-oriented query language, similar to SQL, but
instead of operating on tables and columns, HQL works with persistent objects and their
properties. HQL queries are translated by Hibernate into conventional SQL queries which in
turns perform action on database.
Although you can use SQL statements directly with Hibernate using Native SQL but I would
recommend to use HQL whenever possible to avoid database portability hassles, and to take
advantage of Hibernate's SQL generation and caching strategies
Second-level cache always associates with the Session Factory object. While running the
transactions, in between it loads the objects at the Session Factory level, so that those objects
will be available to the entire application, not bound to single user. Since the objects are already
loaded in the cache, whenever an object is returned by the query, at that time no need to go for
a database transaction. In this way the second level cache works. Here we can use query level
cache also. Later we will discuss about it.
Spring
dependency to a certain other class should get injected into them rather that the class itself
creates / finds this object.
The general concept between dependency injections is called Inversion of Control. A class should
not configure itself but should be configured from outside.
A design based on independent classes / components increases the re-usability and possibility to
test the software. For example, if a class A expects a Dao (Data Access object) for receiving the
data from a database you can easily create another test object which mocks the database
connection and inject this object into A to test A without having an actual database connection.
Spring just simplifies the use of dependency injection by providing a standard way of providing
the configuration and by managing the reference to the created objects.
2. Describe Interceptors
Interceptors are components that intercept calls to classes and methods. They can be used for
adding logging, auditing, and security capabilities without coupling to the business logic.
In DOM, there are no events triggered while parsing. The entire XML is parsed and a DOM tree
(of the nodes in the XML) is generated and returned. Once parsed, the user can navigate the tree
to access the various data previously embedded in the various nodes in the XML.
Differences:
a. DOM parser loads whole xml document in memory while SAX only loads small part of XML
file in memory.
b. DOM parser is faster than SAX because it access whole XML document in memory.
c. SAX parser in Java is better suitable for large XML file than DOM Parser because it doesn't
require much memory.
d. DOM parser works on Document Object Model while SAX is an event based xml parser.
Immutable
What is Immutable?
o Name – String
o Address – String
Reverse a Stack
The problem
Stack is defined by object with pop, push and size functions. Write a function that reverses the
order of the elements in the stack. The function signature is: public void reverse(Stack s)
You can use only other stacks and native/simple temporary variables. The solution can be
explained in words, there is no need to write the full code.
solution 1 – inefficient (most people that answer this part, provide this solution)
Solution:
Each recursive call saves the popped item on the call frame.
When the frames fold back, push the variable to the temporary stack.
Throttling Problem
Server A is deployed with our system that receives transactions which goes through some processing
steps.
In one of the steps a notification request is generated and sent to a 3rd party server.
After a few days from the system deployment, we got a call from the 3rd party system vendor saying
that we keep crashing their server.
After some investigation, it turned out that the vendor’s server supports up to 1000 transactions per
minute while our system supports up to 10000 transactions per minute.
Solution approach:
The requests should be queued and a time based event should wake up every X seconds and
pick up 1000*X/60 requests from the Q and send it to the 3rd party server.
Cache Problem
Suppose you were asked to implement a naïve cache with a simple API – put (K, V), get (K).
The cache is limited in number of entries, once it reached its maximum capacity eviction based on
LRU (least recently used, discards the least recently used items firsts) should be triggered. Suggest an
efficient data structure to support that.
Note that both put and get are accessing the element in the cache therefore refresh the item in the
LRU (e.g. get(k) means that the item is used therefore it become the last in the list of candidates to
be discarded due to LRU eviction).
Solution:
We will use two data structures that maintain the same objects. The data types are Map and Double
Linked list. This solution will provide O(1) complexity for both get and put operations.
The element in the map and in the list will wrap the received V and will include two references
next, prev in order to maintain a double linked list. Assume that the first element in the list is the
least recently used. You will maintain the head and the tail separately.
Put(K, V) api – Create an element that will wrap the V and add it to the Map using the K key. The
element will be added as the last item in the list as well so the element.prev = tail and tail.next =
element and tail = element.
Get(K) api – Get the element from the map using the K key. Now we need to update the list and
move the element to be the last one. Since we have direct access to it once we fetched it from the
Map (no need to scan the list and lookup this element!!) it simply means to update the relevant
next, prev and tail references. The get api will return the element.V.
When the cache reached its maximum capacity to simply need to remove the element from the
head of the list and using the element.K remove it also from the Map
Chess Game
Ask the user to do a design for chess game where 2 players can play a chess game. Ask the candidate
to think about the main classes and objects, define the APIs and describe a game flow using the
classes the candidate designed. The candidate should be able to explain the following:
Expect to see at least the following classes – player, board, game manager, piece interface, piece
implementation – king, queen etc
Verify how chess is checked – should be checked at the end of each move, note that chess can
happen even by pieces that didn’t move but after the last move have a way to reach the opponent’s
king.
Verify that the candidate doesn’t scan the entire board each time there is a need to look up for the
opponent’s king. The candidate should maintain a direct references to the white & black kings.
If the design was good, you can ask the candidate to add a chess clock for the design and see what
are his suggestions