Core Java Interview Questions 2025
Java is one of the most widely used programming languages for building enterprise applications, web services, and Android applications. Preparing for a Java interview requires a strong grasp of fundamental concepts, object-oriented principles, multithreading, collections, exception handling, and Java 8+ features.
This guide provides a structured set of Core Java interview questions along with useful resources to help you prepare effectively.
Basic Java Concepts
- What is Java and what are its main features?
- Explain the difference between JDK, JRE, and JVM.
- What is platform independence in Java?
- What is the difference between path and classpath?
- What are the different types of variables in Java?
- What is the difference between local and instance variables?
- What are static variables?
- What is a constructor?
- What are the different types of constructors?
- What is the difference between break and continue statements?
- What is the difference between final, finally, and finalize?
- What is the difference between throw and throws?
- What is the difference between
==
and.equals()
? - What is the difference between String, StringBuilder, and StringBuffer?
- Why is String immutable in Java?
- What is the String pool?
- What are wrapper classes?
- What is the difference between primitive and reference types?
- What is the difference between stack and heap memory?
- What is the difference between shallow copy and deep copy?
- What is the difference between
System.out.println()
andSystem.err.println()
? - What is the difference between
import
andstatic import
in Java? - What is the difference between
instanceof
andisInstance()
?
Object-Oriented Programming
- What are the main principles of OOP?
- What is the difference between a class and an object?
- What is inheritance?
- Why doesn't Java support multiple inheritance?
- What is method overloading?
- What is method overriding?
- What is polymorphism?
- What is the difference between compile-time and runtime polymorphism?
- What is abstraction?
- What is encapsulation?
- What is the difference between abstract class and interface?
- What is composition?
- What is aggregation?
- What is the difference between association, aggregation, and composition?
- What is the singleton pattern?
- What is the factory pattern?
- What is dependency injection?
- What is the difference between strategy and factory pattern?
- What is the observer pattern?
- What is the decorator pattern?
- What is the difference between tight coupling and loose coupling?
- What is the difference between a concrete class and an abstract class?
- What is the difference between a static method and an instance method?
Data Types and Variables
- What are primitive data types in Java?
- What is type casting?
- What is autoboxing and unboxing?
- What is the difference between
==
and.equals()
? - What is the difference between String, StringBuilder, and StringBuffer?
- Why is String immutable in Java?
- What is the String pool?
- What are wrapper classes?
- What is the difference between primitive and reference types?
- Explain final keyword with variables, methods, and classes.
- What is the difference between stack and heap memory?
- What is the difference between shallow copy and deep copy?
- What is the difference between
int
andInteger
? - What is the difference between
float
anddouble
? - What is the difference between
char
andCharacter
?
Control Flow and Exception Handling
- What are the different types of loops in Java?
- What is the switch statement?
- What is exception handling?
- What is the difference between checked and unchecked exceptions?
- What is the try-with-resources statement?
- Explain the hierarchy of Exception classes.
- What is the difference between throw and throws?
- What is the finally block?
- Can we have try without catch?
- What is exception propagation?
- What is the difference between final, finally, and finalize?
- What is the difference between
Error
andException
? - What is the purpose of the
assert
keyword? - What is the difference between
throw
andthrows
?
Collections Framework
- What is the Collections Framework?
- What is the difference between List and Set?
- What is the difference between ArrayList and LinkedList?
- What is the difference between HashSet and TreeSet?
- How does HashMap work internally?
- What is the difference between HashMap and Hashtable?
- What is the difference between HashMap and ConcurrentHashMap?
- What is the load factor in HashMap?
- What is the difference between fail-fast and fail-safe iterators?
- How to make a collection read-only?
- What is the difference between shallow copy and deep copy?
- What is the difference between
Iterator
andListIterator
? - What is the difference between
Comparable
andComparator
? - What is the difference between
Vector
andArrayList
?
Multithreading
- What is multithreading?
- What is the difference between process and thread?
- What are different ways to create threads?
- What is synchronization?
- What is the difference between synchronized method and synchronized block?
- What is deadlock?
- What is thread starvation?
- What is the volatile keyword?
- What is the difference between
wait()
andsleep()
? - What is thread pool?
- What is the difference between final, finally, and finalize?
- What is the difference between
notify()
andnotifyAll()
? - What is the difference between
yield()
andjoin()
? - What is the difference between
Callable
andRunnable
?
Java 8 Features
- What are lambda expressions?
- What are functional interfaces?
- What is Stream API?
- What is the difference between intermediate and terminal operations in streams?
- What is Optional class?
- What are default methods?
- What is method reference?
- What is the difference between Comparator and Comparable?
- What are the new features in Java 8 Date/Time API?
- What is
forEach()
method in Iterable interface? - What is the difference between
Predicate
andFunction
? - What is the difference between
map()
andflatMap()
in Stream API? - What is the purpose of
Collectors
in Java 8?
Memory Management
- How is memory managed in Java?
- What is garbage collection?
- What are different types of references in Java?
- What is memory leak?
- What is the difference between stack and heap memory?
- What is the OutOfMemoryError?
- What are different types of garbage collectors?
- What is the
finalize()
method? - What is the difference between final, finally, and finalize?
- How to force garbage collection?
- What is the difference between
SoftReference
andWeakReference
? - What is the difference between
Minor GC
andMajor GC
? - What is the purpose of the
System.gc()
method?
File Handling and I/O
- What is the difference between FileInputStream and FileReader?
- What is serialization?
- What is the transient keyword?
- What is externalization?
- What is the difference between Reader/Writer and InputStream/OutputStream?
- What is BufferedReader?
- What is the difference between
getPath()
andgetAbsolutePath()
? - What is NIO?
- What are channels and buffers?
- What is memory-mapped file I/O?
- What is the difference between
FileInputStream
andBufferedInputStream
? - What is the purpose of the
RandomAccessFile
class? - What is the difference between
File
andPath
in Java NIO?
Advanced Concepts
- What is reflection in Java?
- What are annotations?
- What is marker interface?
- What is the difference between abstract class and interface?
- What is composition?
- What is aggregation?
- What is the difference between association, aggregation, and composition?
- What is the singleton pattern?
- What is the factory pattern?
- What is dependency injection?
- What is the difference between
ClassNotFoundException
andNoClassDefFoundError
? - What is the difference between
ClassLoader
andClass
? - What is the purpose of the
Proxy
class in Java?
Java EE Basics
- What is JDBC?
- What is the difference between Statement and PreparedStatement?
- What is connection pooling?
- What is a servlet?
- What is JSP?
- What is the difference between forward and redirect?
- What is the MVC pattern?
- What are Java Beans?
- What is the difference between GET and POST methods?
- What are cookies and sessions?
- What is the difference between
HttpServlet
andGenericServlet
? - What is the purpose of the
Filter
in Java EE? - What is the difference between
JSP
andJSF
?
Best Practices and Design
- What are SOLID principles?
- What is clean code?
- What is the difference between shallow copy and deep copy?
- What is immutable class?
- How to create an immutable class?
- What is the difference between strategy and factory pattern?
- What is the observer pattern?
- What is the decorator pattern?
- What are design patterns?
- What is the difference between composition and inheritance?
- What is the difference between
Builder
andFactory
pattern? - What is the purpose of the
Adapter
pattern? - What is the difference between
Facade
andProxy
pattern?