96 questions in 9 topics
Java Basics Interview Questions
Campus placement basics: the JDK and JVM, data types, operators and their output puzzles.
- What is the difference between JDK, JRE and JVM?
- Why is Java platform independent? Is the JVM platform independent?
- Why is the main method
public static void main(String[] args)? - What are the primitive data types in Java?
Core Java Interview Questions
Strings, equality, boxing, initialization order and how arguments are passed.
- What is the difference between
==andequals()in Java? - What does
==return for string literals andnew String? - Why is String immutable in Java?
- What is the difference between String, StringBuilder and StringBuffer?
OOPs in Java Interview Questions
The four pillars, and where fields and static methods behave differently from instance methods.
- What are the four pillars of OOP in Java?
- What is the difference between method overloading and overriding?
- Does creating a subclass object call the parent constructor?
- What happens when a subclass redeclares a field and overrides a method?
Java Collections Interview Questions
How HashMap, ArrayList and the other collections work inside, and which one to pick.
- Explain the Java Collections Framework hierarchy.
- What is the difference between an array and an ArrayList in Java?
- What is the difference between ArrayList and LinkedList?
- What does
list.remove(1)do on aList<Integer>?
Java Exception Handling Interview Questions
Checked versus unchecked exceptions, finally, try-with-resources and custom exceptions.
- What is the difference between checked and unchecked exceptions?
- What is the difference between
throwandthrows? - Does
finallyrun when thetryblock returns? - What happens with a
returnin bothtryandfinally?
Multithreading in Java Interview Questions
Threads, synchronization, volatile, executors, CompletableFuture and virtual threads.
- What are the ways to create a thread in Java?
- What are the states of a thread in Java (the thread lifecycle)?
- What is a race condition and how does
synchronizedor AtomicInteger fix it? - What does
volatiledo in Java? Does it makecount++thread safe?
Java 8 Interview Questions
Lambdas, functional interfaces, the Stream API and Optional, including how streams evaluate.
- What are the main features introduced in Java 8?
- What is a functional interface?
- How do Java streams work? Show filter, map and reduce.
- Does a stream
filterrun without a terminal operation?
Advanced Java Interview Questions
JVM memory, garbage collection, leaks, generics, class loading, locking and design questions.
- Explain the JVM memory structure: heap, stack and metaspace.
- How does garbage collection work in Java? Which collectors do you know?
- Can Java have memory leaks? Give examples.
- What happens if you change a
HashMapkey afterput?
Java Coding Interview Questions
Short programs from coding rounds, each with a solution you can run.
- How do you reverse a string in Java without using
StringBuilder.reverse()? - Write a Java program to check whether a string is a palindrome, ignoring case and non-letters.
- How do you count the occurrences of each character in a string in Java?
- Write a Java program to check if two strings are anagrams.
Frequently Asked Questions
How should I prepare for a Java interview?
Learn the language first: data types, strings, OOP, exceptions and collections, until you can explain HashMap and predict the output of small programs. Then add Java 8 streams, basic multithreading and 30 to 50 coding problems in Java. Practise each answer aloud in two or three sentences.
What Java topics are asked for freshers compared with experienced candidates?
Freshers get definitions and small programs: JDK vs JVM, OOP pillars, == vs equals, String immutability, ArrayList vs LinkedList, reversing a string. With two or more years of experience the focus moves to how things work: HashMap internals, concurrency, streams, JVM memory and GC, and design questions such as a thread-safe singleton or an LRU cache.
Do I need data structures and algorithms for a Java developer interview?
For most product companies and campus placements, yes: expect at least one coding round in Java. Service companies and some experienced-hire roles lean on core Java, frameworks and projects, but easy array, string and hash map problems still come up.
Which Java version should I prepare with?
Prepare on a current LTS release such as Java 21 or 25, but know which version introduced each feature, since many teams still run Java 8, 11 or 17. Java 8 features (lambdas, streams, Optional) are still common topics.
How long does it take to prepare for a Java interview?
If you already program in Java, two to four weeks of daily practice. Learning the language from scratch, expect two to three months.
Is Spring Boot asked in core Java interviews?
Only for roles that use it, which for experienced backend Java is most of them: expect questions on dependency injection, REST controllers and JPA. Fresher interviews usually stay with core Java, OOP, SQL basics and coding problems.