Advanced Java Questions (with Answers)
Section 1: Core Java Advanced Concepts
1. Explain the difference between checked and unchecked exceptions in Java.
2. What is the significance of the final , finally , and finalize keywords?
3. How does Java implement pass-by-value for objects?
4. Describe the difference between HashMap , LinkedHashMap , and TreeMap .
5. How does the equals() method differ from == ?
6. What is the difference between String , StringBuilder , and StringBuffer ?
7. Explain method overloading vs method overriding.
8. How does Java handle memory management and garbage collection?
9. What are the differences between ArrayList and Vector ?
10. What is the purpose of the transient keyword?
11. Explain the volatile keyword and its usage.
12. How does synchronized work in Java?
13. Explain Java's access modifiers and their scope.
14. What is the difference between deep copy and shallow copy?
15. Describe how serialization works in Java.
Section 2: Java Concurrency & Multithreading
1. Explain the life cycle of a thread in Java.
2. What are Thread and Runnable interfaces? Compare them.
3. How do you create a thread-safe singleton in Java?
4. What is the difference between wait() and sleep() ?
5. Explain deadlock and how to prevent it.
6. How does the ExecutorService work?
7. Describe ReentrantLock and its advantages over synchronized .
8. What is a CountDownLatch and where is it used?
9. Explain CyclicBarrier with an example.
10. How does ThreadLocal work and when would you use it?
Section 3: Java Design Patterns & OOP Concepts
1. Explain the Singleton pattern with thread safety.
2. What is the Factory pattern and when is it useful?
3. Explain the Observer pattern.
4. Describe the Decorator pattern with an example.
5. What are SOLID principles? Give examples.
6. How does the Strategy pattern work?
7. Explain the Adapter pattern.
8. What is the difference between abstract class and interface?
9. Explain the Proxy pattern.
10. Describe the Builder pattern.
1
Section 4: Java Streams & Lambda Expressions
1. Explain the concept of functional interfaces.
2. How does a lambda expression differ from an anonymous class?
3. What is the difference between map() , flatMap() , and filter() in streams?
4. Explain collect() and common collectors.
5. How do you use Optional to avoid NullPointerException ?
6. Describe the difference between sequential and parallel streams.
7. Explain reduce() in Java streams.
8. How do you sort a stream by multiple fields?
9. Describe method references and their types.
10. Explain short-circuiting operations in streams.
Section 5: Java Memory Management & JVM Internals
1. How does JVM memory model work (Heap, Stack, PermGen/Metaspace)?
2. What is the role of ClassLoader in Java?
3. Explain strong, weak, soft, and phantom references.
4. Describe the different types of garbage collectors in Java.
5. How do you monitor and optimize memory usage in Java applications?
Section 6: Advanced Java Interview Questions
1. How does ConcurrentHashMap achieve thread safety?
2. Explain the difference between wait() and notifyAll() .
3. How would you implement a producer-consumer problem using Java?
4. What is the difference between Callable and Runnable ?
5. Explain the concept of Java memory leaks and how to detect them.
6. How does Java support immutability?
7. Describe the internals of HashMap in Java 8.
8. How does ForkJoinPool work?
9. Explain the difference between SoftReference and WeakReference .
10. What are the best practices to optimize Java performance?
This document can now be converted into a PDF with proper formatting.