1. Java Fundamentals
What is Java?
What is Java?
Explain JVM, JRE, and JDK
Explain JVM, JRE, and JDK
- JVM: Executes Java bytecode.
- JRE: Contains JVM + core libraries to run Java apps.
- JDK: Includes JRE + development tools (compiler, debugger).
What are access modifiers in Java?
What are access modifiers in Java?
public, protected, default, and private — control visibility of classes, methods, and variables across packages.Difference between stack and heap memory?
Difference between stack and heap memory?
Heap: Stores objects created using
new. Managed by garbage collector.What are wrapper classes?
What are wrapper classes?
int → Integer). Used in collections and generics.2. Object-Oriented Programming
What are the main OOP principles?
What are the main OOP principles?
- Encapsulation: Hiding internal details via getters/setters.
- Inheritance: Reusing code by extending classes.
- Polymorphism: Method overriding and overloading.
- Abstraction: Hiding implementation using abstract classes/interfaces.
Difference between abstraction and encapsulation?
Difference between abstraction and encapsulation?
Encapsulation hides internal state and controls access.
What is method overloading vs overriding?
What is method overloading vs overriding?
- Overloading: Same method name, different parameters (compile-time).
- Overriding: Subclass redefines parent method (runtime).
Can you explain 'this' and 'super' keywords?
Can you explain 'this' and 'super' keywords?
thisrefers to current class instance.superrefers to parent class members or constructor.
What are constructors in Java?
What are constructors in Java?
3. Java Basics & Control Flow
Difference between == and equals()?
Difference between == and equals()?
== compares references (memory address)..equals() compares object content if overridden.What is a static keyword?
What is a static keyword?
Difference between break and continue?
Difference between break and continue?
break exits a loop; continue skips the current iteration and continues to the next one.What is final keyword used for?
What is final keyword used for?
final makes variables constants, prevents method overriding, and stops class inheritance.What are varargs in Java?
What are varargs in Java?
.... Example: void add(int... nums).4. Collections Framework
What is the Java Collections Framework?
What is the Java Collections Framework?
Difference between ArrayList and LinkedList?
Difference between ArrayList and LinkedList?
- ArrayList: Fast random access, slow insertion/deletion.
- LinkedList: Fast insertion/deletion, slow random access.
Difference between HashMap and Hashtable?
Difference between HashMap and Hashtable?
- HashMap: Not synchronized, allows null keys/values.
- Hashtable: Synchronized, legacy, doesn’t allow nulls.
Explain Set vs List vs Map
Explain Set vs List vs Map
- Set: No duplicates.
- List: Ordered, allows duplicates.
- Map: Key-value pairs, no duplicate keys.
What are Concurrent Collections?
What are Concurrent Collections?
ConcurrentHashMap, CopyOnWriteArrayList designed for multithreaded environments.5. Exception Handling
What is exception handling?
What is exception handling?
try, catch, finally, and throw.Difference between checked and unchecked exceptions?
Difference between checked and unchecked exceptions?
Unchecked: Runtime (e.g., NullPointerException).
What is finally block used for?
What is finally block used for?
Explain custom exceptions
Explain custom exceptions
Exception or RuntimeException for domain-specific error handling.Difference between throw and throws?
Difference between throw and throws?
throwis used inside methods to explicitly throw an exception.throwsdeclares exceptions a method can throw.
6. Multithreading & Concurrency
What is a thread in Java?
What is a thread in Java?
Thread class or Runnable interface.Explain the life cycle of a thread
Explain the life cycle of a thread
Difference between start() and run()?
Difference between start() and run()?
start() begins a new thread; run() executes in the same thread like a normal method call.What is synchronization?
What is synchronization?
synchronized keyword or locks.Explain volatile keyword
Explain volatile keyword
7. Java 8 & Functional Programming
What are lambda expressions?
What are lambda expressions?
(x, y) -> x + y. Used with streams and functional interfaces.What are streams in Java 8?
What are streams in Java 8?
What is Optional class?
What is Optional class?
NullPointerException.What are method references?
What are method references?
::. Example: System.out::println.Explain functional interfaces
Explain functional interfaces
Runnable, Supplier, Consumer). Annotated with @FunctionalInterface.8. Memory Management & Garbage Collection
How does garbage collection work?
How does garbage collection work?
System.gc(), but it’s not guaranteed.What are strong, weak, and soft references?
What are strong, weak, and soft references?
- Strong: Prevent GC.
- Weak: Collected when weakly reachable.
- Soft: Collected only when memory is low.
What are memory leaks in Java?
What are memory leaks in Java?
How to prevent OutOfMemoryError?
How to prevent OutOfMemoryError?
Explain finalize() method
Explain finalize() method
try-with-resources for cleanup.9. Spring & Framework Concepts
What is Spring Framework?
What is Spring Framework?
Explain dependency injection (DI)
Explain dependency injection (DI)
@Autowired.What is the difference between BeanFactory and ApplicationContext?
What is the difference between BeanFactory and ApplicationContext?
- BeanFactory: Basic container.
- ApplicationContext: Adds enterprise features like event handling and AOP.
Explain Spring Boot
Explain Spring Boot
What are common Spring annotations?
What are common Spring annotations?
@Component, @Service, @Repository, @Controller, @RestController, @Autowired, @Configuration, @Bean.10. Java Interview Best Practices
Common performance optimization tips
Common performance optimization tips
Common mistakes to avoid
Common mistakes to avoid
equals() and hashCode(), neglecting resource closure, and ignoring concurrency issues.How to prepare for coding interviews?
How to prepare for coding interviews?
Most asked Java interview questions
Most asked Java interview questions
- Difference between
HashMapandHashtable - Explain
synchronizedvsvolatile - How does JVM memory work?
- Explain OOP principles
- What are lambda expressions and streams?
Tips for Java system design interviews
Tips for Java system design interviews
Conclusion & Interview Tips
Key Focus Areas
- OOP concepts and Java 8+ features
- Multithreading, collections, and memory management
- Spring Boot fundamentals and dependency injection
- Clean code and exception handling practices
During the Interview
- Explain your logic clearly
- Discuss time and space complexity
- Mention trade-offs and alternatives
- Demonstrate debugging and testing approaches