93 Java interview questions you should be asking
March 16, 2020
min read

93 Java interview questions you should be asking

Ana Gospodinova
Ana Gospodinova

If you are a developer, head over to this blog post to prepare yourself for the next Java job interview.

Or are you looking to hire a Java developer for your team or a client? There are plenty of Java developers out there waiting to grab their next best job opportunity so perhaps it’s time to boost your recruitment results too. 

One effective way is to ask the right questions in the interview. This will ensure you don’t just hire the person with the perfect skill set but is a cultural fit too. If you’re not sure what those questions should be - no worries, we’ve got you covered - whether you have an IT background or not. 

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 you can use in an initial call with your applicant. Having a quick 15-minute phone or video call is recommended to determine whether a candidate 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 the applicant did not work with Java in recent years, the chances are slim that he or she's up to speed on things. But keep an open mind, you can use this as an opportunity to find out why or just how motivated they are to work at your company.

2. How many years of experience do you have in Java? 

Tip: This gives you a heads up about their level of experience and whether they have enough to suit your opening - their response also enables you 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: The candidate’s response to this question will give you an idea of how dedicated he/she is when it comes to continuing to learn and grow their 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 you don’t know much about the person sitting across from you either. Try a few of 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, it’s best to test the waters and ask the basics of Java development. These are probably questions a non-tech person can ask and still feel 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 new 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 the candidate has performed so far and whether you’re looking to fill a junior or senior position. 

At this stage of the process, we recommend involving someone from the tech team, developers and/or product owners who will be working together with this person day in and day out. It enables you to thoroughly check their technical skills and know-how as well as see how good the cultural fit is. 

As the questions get more complex and detailed, it might be a good idea to leave the answering up to your trusted in-house Senior Developer. There’s plenty to choose from and you’re sure to put your candidates to the test by using them.

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 you haven’t already done so - a technical task challenge should be your next move. Giving your candidate a hands-on task truly shows how they work and their thinking process.

You can then simultaneously move onto more difficult questions, many of which we list below. Which of them makes sense for your company differs depending on several things. 

Also, use the advanced Java interview questions to ask the candidate about their carried out task thoroughly. These questions, along with general advanced Java interview questions, definitely show whether the candidate is 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 new() 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 to hire a Java Developer you should be putting your company out there. Check out our WeAreDevelopers for Companies page. Here you can get access to a community of over 30,000 top-notch developers, set up a company profile they won’t be able to resist and start firing out those questions in no time!


#Wanted and #Misunderstood: A Developer Survey 2022

Download now

#Wanted and #Misunderstood: A Developer Survey 2022

Jetzt downloaden