93 Java interview questions you should prepare for
October 27, 2020
You’re looking to get hired as a Java developer? Good call! Java is used everywhere and provides numerous job opportunities, not only for juniors, but especially for intermediates and seniors.
According to Stack Overflow Developer Survey in 2020 Java is the 5th most popular technology world-wide, even though it is might not the most loved one.
Here’s a list of our top 93 Java interview questions that will walk you through the process of a Java developer interview – step by step.
Java interview questions for screening
Screening questions are questions recruiters use in an initial call with you. Being invited to a quick 15-minute phone or video call is due to determine whether you should be invited to an interview on-site – or not.
1. Which technologies, listed in your resume, have you used in a job scenario during the past 2 years?
Tip: If you did not work with Java in recent years, the chances are slim that you are up to speed on things. No reason to surrender at the first question. Give yourself an update. You can use this as an opportunity to show why or just how motivated you are to work at your company.
2. How many years of experience do you have in Java?
Tip: This gives the recruiter a heads up about your level of experience and whether you have enough to suit your opening – your response will enable your counterpart to prepare either basic or advanced questions further down the line (which we’ve prepared for you below).
3. Are you passionate about working with Java, and do you want to develop your skills in this field further?
Tip: Your response to this question will give the recruiter an idea of how dedicated you are when it comes to continuing to learn and grow your skillset. Java, as with most software development positions, requires a dedication to improve and hone your skill set – updates are becoming more and more frequent and what you learned two years ago is not relevant today.
Java interview questions: Ice-breakers
Interview situations can be a bit uncomfortable, some interviewees get nervous, and the recruiter does not know much about the person sitting across from them either. Use these ice breaker questions to get into the swing of things:
4. Why did you apply for this Java development position?
5. How did you get into Java development?
6. Tell me about one recent major Java project you were involved in and what role you played in it.
Next, the recruiters might want to test the waters and ask the basics of Java development. These are probably questions a non-technical recruiter can ask you because he/she still feels comfortable with. We also added the typical answers to these basic Java interview questions, so that you can be prepared.
Basic Java interview questions
7. What is Java?
Answer: Java is a programming language that has become very popular. It is a platform-independent programming language mainly used for coding android but is also popular with edge device technology and IoT (Internet of Things) devices.
Java is also similar to C and C++ but is simpler and enforces an object-oriented programming model. People use Java for applications that can run on a single computer or can be spread amongst servers. Java is known to be the write once, run anywhere coding language.
8. What features does Java have?
Answer: The most commonly known Java features and advantages are:
High performance: the Java compiler allows for high performance as it compiles the Java code into bytecode, it is then fed to the Java Virtual Machine and converted into machine-level code.
Based on C and C++: C and C++ are the predecessors of the modern programming languages Python and Java which is why having an understanding of C and/or C++ is useful in Java.
Object-oriented: As opposed to C++, which is semi-object-oriented, Java extends to become fully object-oriented.
Multithreading: comes built into Java
Platform independence: Java is known as the write once, run anywhere language - you can run your code on any system that runs Java Virtual Machine
Secure: safety features are built into Java as you code along, with enough features to make it difficult to get in from the outside
9. Which Java frameworks are you familiar with? OR you listed framework X on your resume. Do you think it makes sense to use it?
Answer: Frameworks are large bodies (usually many classes) of prewritten code to which you add your code - every company tends to use their framework. If the developer is familiar with the framework your company is using, it will make things easier.
10. When you joined your last company at what stage was the project? Were you responsible for choosing the technology or setting up the project? If yes, why did you choose a certain technology?
Tip: This will give you insight as to how much responsibility the candidate has taken in the past, whether they are active in coming up with ok bet casino solutions and taking on responsibility.
11. We all make mistakes sometimes. What was the one project decision where you made a mistake - what was it? why did it happen? And how would you do it differently now?
Tip: This is an excellent indicator of how the person deals with hiccups along the way, unexpected turns, and how they tackle challenges.
12. Java changes – all the time. What versions do you know and what changes did they bring?
Tip: Java is continuously evolving, and although having the core skills is essential, having someone who is familiar with the particular versions you’re using is also very important.
A developer usually lists the versions they’ve used most recently on their CV. The most prevalent version required is Java 8. This should be the primary focus when questioning a developer. They should also be able to demonstrate that they’re up to date with the most recent releases of Java, Java 9 and Java 10, both of which are rapid release versions.
Once you have covered these basics, it’s time to move on to medium level or advanced Java interview questions – depending on how you have performed so far and whether you’re looking for a junior or senior position.
At this stage of the process, expect someone from the tech team becoming involved, developers and/or product owners who will be working together with you day in and day out. It enables the recruiter to thoroughly check your technical skills and know-how. Use the change to see how good the cultural fit between you and a future colleague is.
As the questions get more complex and detailed, check out additional training resources.
Medium-level Java interview questions
13. What is method overloading in Java?
14. What is method overriding in Java?
15. Path and classpath variables – what’s the difference?
16. Explain what is the Java Reflection API?
17. Static import – what is it?
18. Java: Pass By or Pass By Reference?
19. Explain what is Enum in Java?
20. What’s the final Keyword in Java?
21. Explain what are the access modifiers in Java?
22. Composition in Java – what does it mean?
At this stage of the process – if not already happened – expect technical task challenges. Showing your skills with a hands-on task truly shows how you work and your thinking process is.
The interview will then simultaneously move onto more difficult questions, many of which we list below. Which of them makes sense for you differs depending on several things.
Also, take a look on the advanced Java interview questions. These questions, along with general advanced Java interview questions, definitely show whether you are up for the challenge or not.
Advanced Java interview questions
23. Marker interface: what is it?
24. Explain the difference between a user thread and a daemon thread.
25. What is OutOfMemoryError in Java?
26. Explain Compare and Swap (CAS) algorithm.
27. What is the volatile keyword in Java?
28. Explain the term Java timer class.
29. How do you go about scheduling a task to run after the specific interval?
30. How to write a custom exception in Java?
31. CountDownLatch in Java – what is it?
32. Is it possible to have an empty catch block?
33. An exception is thrown by the main method - what happens?
34. What is JDBC API and when should we use it?
35. Explain the different types of JDBC drivers.
36. DBC ResultSet – what is it?
37. Explain what is “dirty read” in JDBC? Which isolation level prevents dirty read?
38. What is 2 phase commit?
Core Java interview questions
39. How would you create an immutable object in Java?
40. Is Java Pass by Reference or Pass by Value?
41. What is the use of the finally block? Is finally block in Java guaranteed to be called? When finally block is NOT called?
42. Why are there two Date classes; one in Java.util package and another in Java.sql?
43. What is Marker interface?
44. Why main() in Java is declared as public static void main?
45. What is the difference between creating String as ok bet casino() and literal?
46. How does substring() inside String works?
47. Explain the working of HashMap.
48. Difference between interfaces and abstract classes?
49. When do you override hashCode and equals()?
50. Why finalize() method should be avoided?
51. Why HashMap should not be used in multithreaded environment? Can it cause an infinite loop as well?
52. Explain abstraction and encapsulation? How are they related?
53. Difference between interfaces and abstract classes?
54. How StringBuffer save the memory?
55. Write a Java program to create deadlock in Java and fix it?
56. What happens if your Serializable class contains a member which is not serializable? How do you fix it?
57. Explain transient and volatile keywords in Java?
58. What's the difference between Iterator and ListIterator?
59. What's the difference between deep copy and shallow copy?
60. What is synchronization? Class level locking and object-level locking?
61. What's the difference between sleep() and wait()?
62. Can you assign null to this reference variable?
63. What is the difference between && and &?
64. How to override equals and hashCode() methods?
65. Explain all access modifiers.
66. What is garbage collection? Can we enforce it?
67. What is native keyword?
68. What is serialization? Explain the catches.
Java String interview questions
69. Is String a keyword in Java?
70. Why are strings immutable?
71. What is String constant pool?
72. What is the usage of the function intern()?
73. How can you match regular expressions?
74. Explain the string comparison with equals() and ‘==’?
75. What is the memory leak issue in String class?
76. How does String work in Java?
77. What are different ways to create String Object?
78. Explain how to check if String is Palindrome.
79. How to remove or replace characters from String.
80. Explain how to make String uppercase or lower-case?
81. How would you compare two Strings in Java?
82. Can we use String in the switch case?
83. Write a program to print all permutations of String.
84. Write a Java program to reverse each word of a given string.
85. How can you Split String in Java?
86. Why is Char more commonly used and not String for a storing password?
87. Is String thread-safe in Java?
88. Why is String a popular HashMap key in Java?
89. What is the difference between String, StringBuffer and StringBuilder?
90. How can you concatenate multiple strings?
91. Explain how many objects are created with string initialization code?
92. How do you count the number of occurrences of each character in a string?
93. Write a Java program to reverse a string.
Where to go from here?
Now that you’ve got all of 93 Java interview questions – it’s time to put them to good use. If you’re currently looking for a job as a Java Developer check out our job board on Java jobs for seniors, intermediates and juniors.
About the author:
Ready to take charge of your dev career?
Join Europe's leading job platform for software developers!