Most Asked Java Interview Questions
Java Basics
1. What happens when a program is loaded in compile time and run time in detail?
2. What are different types of access modifiers?
3. Can the static method override? Explain
4. Difference between static methods, static variables, and static classes in java.
5. Difference between static and final keyword.
6. What is the main objective of garbage collection?
7. What are shallow copy and deep copy in java?
8. difference between equals() method and equality operator (==) in Java?
9. Explain Serialization and deserialization
10. What is the use of SerialVersionUID?
11. Advantages and disadvantages of serialization and deserialization
12. What is a classloader? And how class loads in Java
13. Difference between JVM, JRE, and JDK.
14. Can we declare the main method as non-static in public static void main ()?
15. What is wrapper class? and why do we need it?
16. How many ways you can take input from the console?
17. What is abstract , Synchronized , transient and volatile keyword?
18. What’s the difference between the methods sleep() and wait()
19. What is a singleton class in Java? And How to implement a singleton class?
20. What is a Comparator and Comparable in java?
21. What are different types of memory allocation in java ?
22. What is Late Binding?
23. What are different storage area in JVM ?
Java - Strings
1. What are the differences between String , StringBuffer and StringBuilder?
2. Why is StringBuffer called mutable?
3. How is the creation of a String using new() different from that of a literal?
4. what are the reasons behind making strings immutable in Java?
5. Why String class is final?
6. Why Char Array is better to store passwords than String ?
7. What is String Constant Pool ?
8. Is String thread-safe in Java ?
9. Check the differences between these and also check how many objects will form in heap
area and string constant pool ?
String s1 = new String(“John”);
String s2 = new String(“william”);
String s3 = new String(“John”);
String s4 = “Chris”;
String s5 = “John”;
String s6 = “Chris”;
Java Exception Handling
1. In what case finally block will not be executed ?
2. Difference between Checked and Unchecked Exceptions
3. What is Try block with resource?
4. Difference between an Error and an Exception.
5. What is the difference between Checked Exception and Unchecked Exception?
6. Is it necessary that each try block must be followed by a catch block?
7. What is exception propagation?
8. What will happen if you put [Link](0) on the try or catch block? Will finally block
execute?
9. What purpose do the keywords final, finally, and finalize fulfill?
10. Explain the use of final keyword in variable, method and class.
11. Is it possible that the ‘finally’ block will not be executed? If yes then list the case.
12. What is the difference between the ‘throw’ and ‘throws’ keyword in java?
Java Collections
1. Learn about different components of Java collections.
2. Difference between HashMap and LinkedHashMap.
3. Explain how Hashmap or Hashtable works in Java?
4. What is the HashSet class in Java and how does it store elements?
5. What makes a HashSet different from a TreeSet?
6. Difference between Set and Map
7. What is the use of Treemap?
8. List down various implementations of Set?
9. What is BlockingQueue? When to implement it?
10. What is the ConcurrentHashMap in Java and do you implement it?
11. What is iterator?
12. What is the difference between Iterator and ListIterator?
13. What is the difference between Comparable and Comparator?
14. Explain the FailFast iterator and FailSafe iterator along with examples for each.
Java OOPS
1. What is the difference between static (class) method and instance method?
2. What are the different ways to create objects in Java?
3. What is Object Cloning?
4. Difference between Coupling and Cohesion?
5. What is the difference between this() and super() in Java?
6. What is constructor overloading?
7. What is constructor chaining?
8. How many types of constructors are used in Java?
9. What is copy constructor in Java?
10. What are some features of the Interface ?
11. What is marker interface?
12. What is externalizable interface?
13. Difference between Abstraction and Encapsulation.
14. What are the differences between abstract class and interface?
15. What do you mean by data encapsulation?
16. What are benefits of data encapsulation
17. What are the different types of inheritance in Java?
18. What is multiple inheritance? Is it supported by Java?
19. What is association, aggregation and composition?
20. What is Polymorphism? And how many types of polymorphism is there ?
21. What is the difference between method overriding and method overloading ?
22. Can we override the static method or private method?
23. What is abstraction? And how can it be achieved?
24. When Abstract methods are used?
25. How can you avoid serialization in the child class if the base class is implementing the
Serializable interface?
Java Multithreading
1. What is Thread in Java?
2. What are the ways of implementing thread in Java?
3. Difference between start() and run() method of Thread class?
4. Difference between wait() and sleep() methods?
5. What’s the difference between notify() and notifyAll()?
6. What's the difference between thread and process?
7. Difference between Runnable and Callable Interface?
8. Different states of Thread ?
9. What is Thread pool?
10. What is Thread priority?
11. How to join two threads?
12. Explain Thread Lifecycle.
13. What are the Different Types of threads in Java?
14. How to Create a User thread?
15. What is deadlock in multithreading?
16. What is Daemon Thread in Java?
17. How to Make User Thread to Daemon Thread?
18. Can we Overload or override run() method?
19. Can we Overload or override start() method?
20. What is synchronized method and synchronized block? Which one should be preferred?
Java Generics
1. What is Generics in Java? What are the advantages of using Generics?
2. How Generics works in Java ? What is type erasure?
3. How do you declare generic class in java?
4. How to write parametrized class in Java using Generics?
5. Can we use Generics with Array?
6. What Is Type Inference?
7. What is the difference between List<? extends T> and List <? super T>?
8. Difference between List<Object> and raw type List in Java?
9. Difference between List<?> and List<Object> in Java?
10. What do you understand by wildcards in generics?