Java Developer Interview Questions & Answers
40 questions for Java Developer interviews — 26 easy, 12 medium, 2 hard.
About the Java Developer role
A Java developer builds and maintains server side applications using core Java, OOP and common libraries. Freshers in this role write features, fix bugs, write unit tests and work with SQL databases under senior guidance. It is the most common entry role at IT services companies and global capability centres, and it builds the base for backend, full stack and architect careers.
What is the difference between method overloading and method overriding?
Show answer
Write a Java method to check whether a string is a palindrome, ignoring case and non-letters.
Show answer
What are the key patterns used in microservices built with Spring Boot?
Show answer
Tell me about a time you improved performance by choosing a better data structure.
Show answer
What is the difference between JDK, JRE and JVM?
Show answer
Objects used as HashMap keys cannot be found after insertion. What could be wrong?
Show answer
What is the difference between start() and run()?
Show answer
Write a Java solution for the Two Sum problem using a HashMap.
Show answer
What is constructor chaining?
Show answer
Find the first non-repeating character in a string.
Show answer
What is the difference between checked and unchecked exceptions?
Show answer
Code builds a large CSV report with String += inside a loop and it is very slow. Why and what is the fix?
Show answer
Why are String objects immutable in Java?
Show answer
What is the difference between an abstract class and an interface in modern Java?
Show answer
What is the String constant pool?
Show answer
What are fail-fast and fail-safe iterators?
Show answer
Remove duplicates from a list while keeping the original order.
Show answer
Why did you choose Java for your career?
Show answer
Count the frequency of each character in a string using Java.
Show answer
What is the difference between final, finally and finalize?
Show answer
You need to remove items from an ArrayList while looping over it. How do you do it safely?
Show answer
What are the four pillars of OOP? Explain with Java examples.
Show answer
A HashMap shared by many threads sometimes loses updates. How do you fix it?
Show answer
What are text blocks in Java?
Show answer
An application gets StackOverflowError in a recursive method. What do you do?
Show answer
What is try-with-resources?
Show answer
What is the difference between == and equals() in Java?
Show answer
How do you make a class immutable in Java?
Show answer
Why does Java not support multiple inheritance of classes?
Show answer
Why is Java called platform independent?
Show answer
What is CompletableFuture and how is it better than Future?
Show answer
Sort a list of employees by department, then by salary descending.
Show answer
Write a Java program to check whether a number is prime.
Show answer
What is the difference between Comparable and Comparator?
Show answer
What is the difference between a static and an instance variable?
Show answer
How do you handle disagreement with a reviewer about your code?
Show answer
A team member compares two Integer values with == and the check fails only for large numbers. Explain.
Show answer
Explain the main memory areas of the JVM.
Show answer
What is the difference between throw and throws?
Show answer
Frequently asked questions
What does a Java Developer do?
A Java developer builds and maintains server side applications using core Java, OOP and common libraries. Freshers in this role write features, fix bugs, write unit tests and work with SQL databases under senior guidance. It is the most common entry role at IT services companies and global capability centres, and it builds the base for backend, full stack and architect careers.
Which skills are tested in a Java Developer interview?
Expect questions on Core Java, OOP, Collections, SQL, Git. Most rounds also ask you to explain a project and solve one practical problem live.
How do I prepare for a Java Developer interview?
Revise Java Basics and JVM, OOP in Java, Collections Framework, Strings and Exception Handling first using the topic sheets, practise the questions on this page aloud, then do one full mock interview to practise timing.