Java Interview Questions

Core Java Questions

1. What is Java?
2. What are the main features of Java?
3. What is the difference between JDK, JRE, and JVM?
4. What is the difference between `==` and `.equals()`?
5. What is the `final` keyword in Java?
6. What are the four principles of OOPS?
7. What is the difference between method overloading and overriding?
8. What is the difference between an abstract class and an interface?
9. What is a singleton class?
10. What is the `super` keyword used for?
11. What is the difference between checked and unchecked exceptions?
12. What is the `finally` block used for?
13. What is the difference between `throw` and `throws`?
14. What is the difference between `ArrayList` and `LinkedList`?
15. What is the difference between `HashMap` and `HashTable`?
16. What is the purpose of the `equals()` and `hashCode()` methods?
17. What is the difference between `Thread` and `Runnable`?
18. What is the `synchronized` keyword used for?
19. Write a program to reverse a string?
20. Write a program to check if a number is prime?
21. What is the difference between `public`, `private`, `protected`, and default access modifiers?
22. What is the difference between `String`, `StringBuilder`, and `StringBuffer`?
23. What is the `static` keyword used for?
24. What is a constructor?
25. What is the difference between a constructor and a method?
26. What is polymorphism?
27. What is encapsulation?
28. What is the difference between `this` and `super`?
29. What is an abstract class?
30. What is an interface?
31. What is a `try-catch` block?
32. What is a custom exception?
33. What is the difference between `final`, `finally`, and `finalize`?
34. What is the difference between `ArrayList` and `Vector`?
35. What is the difference between `HashSet` and `TreeSet`?
36. What is the difference between `HashMap` and `TreeMap`?
37. What is the purpose of the `Comparable` and `Comparator` interfaces?
38. What is a thread?
39. What is the difference between `start()` and `run()` methods in threads?
40. What is the `volatile` keyword used for?
41. What is the difference between `ArrayList` and `LinkedList`?
42. What is the difference between `HashMap` and `ConcurrentHashMap`?
43. What is the purpose of the `transient` keyword?
44. What is the difference between `Serializable` and `Externalizable`?
45. What is the difference between `wait()` and `sleep()`?
46. Write a program to find the factorial of a number?
47. Write a program to check if a string is a palindrome?
48. Write a program to find the largest number in an array?
49. Write a program to reverse a linked list?
50. Write a program to find the Fibonacci series?