This article have been designed to get you prepared with the questions you may encounter during a technical interview for the subject of Java Programming Language. Typical jobs descriptions requiring Java skills are Java Backend programmer and Java Fullstack programmer.
As per my experience, most of the questions are related to:
- the programming language particularities (syntax, core API)
- problem solving (algorithms, data structures)
- application design / architecture (design patterns, object oriented programming, best practices…).
You'll find below a summary of these question categories and some examples. I hope this will help for your next tech interview!
Java language questions are mainly about classes, methods, objects, syntax and APIs.
Questions relating to the Java language check the developer’s ability to use functionalities that are well-known. Using the correct APIs and data structures determine the developer's level of experience in the practice of the Java programming language. This skill is particularly important for a developer who has to be quickly operational in a Java working environment. See below a list of the common questions which can be asked by technical recruiters:
- What is the purpose of the method
public static void mainin a Java program?
- What is the difference between
- What is an
- When would you use an
abstractclass instead of an
- What are the differences between a
publicmethod and a
- What is a
- What is an
- Is it a good practice to catch a
- What is the keyword to use in a method signature to allow non-catching of an exception in this method?
- What is the latest version of Java?
- What is the purpose of a garbage collector?
- What is the difference between a
Threadmethod is called when a thread starts?
- Is it possible to update a
Stringobject (without using introspection)?
- What is the contract between the methods
- Who is James Gosling?
An example of very simple task consists in writing a method which takes a string
str as parameter and returns
true if it equals to
Java Problem Solving Questions
This skill corresponds to the developer's ability to evaluate and resolve a problem by writing an efficient algorithm in Java. Any developers should be able to solve simple problems but advanced analytical skills and logical reasoning are essential when your are hiring Java R&D developers. Problem Solving exercises cover several topics like the graph theory, dynamic programming and the number theory. Most of the time problem solving questions require to write code or pseudo code directly in a code editor or, sometimes, in front of a white board. See below some questions:
- What are time and space complexity?
- What is the O-notation?
- What is the time complexity of binary search?
- Given a pointer to the head node of a linked list, reverse this linked list
- Give the name of 3 sorting algorithms and explain their logic
- What is the difference between DFS and BFS?
- Implement a recursive and an iterative method to compute a given Fibonacci number
An example of a simple problem is:
From a given array of natural numbers, return the distance between the two closest numbers.
A basic solution consists in: for each number, compare it to all the other numbers. This solution takes a long time to process large data sets, its time complexity is O(n²) then this implementation can fail on big data sets. A more efficient solution consists in a two steps algorithm:
- sort the array using a built-in function like
Arrays.sort()which has a time complexity of O(n log n).
- iterate through the sorted array and compare each number to the previous one to find the two closest.
See? This is much better!
Java Design Questions
Having a good understanding of the design patterns, OOP (object-oriented programming) and unit tests give an indication of the developer's ability to implement standard solutions to common problems. A developer with a good level of proficiency in this skill will contribute to increase the maintainability and the extensibility of applications. This skill is particularly important for senior Java developers who will have to work on the architecture of applications to design long-term solutions.
This is a simple question example:
A general rule of thumb is to prefer interface over implementation, it improves code maintenance, testability and code portability.
Map getTable() is the expected answer.
Java Readability Questions
This metric focus on the developer’s ability to follow the Java guidelines and best practices. A high score means that the code is easily understandable by other programmers, easier to maintain and to debug. For example,
private String Name; will impact the readability score because it does not respect the Java naming convention:
Name should be written
Java Reliability Questions
str.equals("Hello World") upper? What happens if
null? 🧐 This kind of error is like a mine silently waiting in a program.
Reliability refers to the developer's ability to achieve solutions that address specific cases like corner and edge cases. The higher this skill, the higher the developer anticipates possible errors and minimizes those to build robust programs.
About Programming tests
Coding tests are one of the most efficient ways to screen developers before hiring.
The CodinGame Java online tests assess candidates' skills. They are perfect for pre-employment screening for developers. Most of the coding interview tools focus only on the candidates' ability to write efficient algorithms but algorithms are a tiny part of software development, mastering them is one skill among several other important skills. CodinGame Assessment provides tests covering a wide scope of technical characteristics to evaluate candidates' ability to write good Java programs.
They provide a proven model for identifying and hiring proficient developers. Candidates code their way through real, practical problems that they could encounter in a company (such as finding a bug in a defective piece of code or properly synchronizing a multi-threaded application), enabling recruiters to measure their coding skills objectively and efficiently.
Candidates’ code is automatically analyzed and recruiters are provided with performance metrics. Once completed, a test report is available to download and share to easily compare and shortlist candidates.