Core Java Interview Questions and Answers
21. What is garbage collection in Java?
Garbage collection is the process by which Java programs perform automatic memory management. The
garbage collector reclaims memory occupied by objects no longer in use.
22. What are Java annotations?
Annotations provide metadata for the Java code. They are used for information that can be processed at
compile-time or runtime. Examples include @Override, @Deprecated, and @FunctionalInterface.
23. What is the difference between HashMap and Hashtable?
HashMap is non-synchronized and allows one null key and multiple null values. Hashtable is synchronized
and does not allow null keys or values.
24. What is the Java Stream API?
Introduced in Java 8, the Stream API provides a functional approach to processing collections of objects. It
supports operations like filter, map, and reduce.
25. What is the difference between ArrayList and LinkedList?
ArrayList is based on a dynamic array, while LinkedList is based on a doubly linked list. ArrayList is faster for
random access, whereas LinkedList is better for insertions and deletions.
26. What are functional interfaces in Java?
A functional interface has exactly one abstract method. Examples include Runnable, Callable, and
Consumer. They are used extensively in lambda expressions.
27. What is a lambda expression?
A lambda expression is a concise way to represent an anonymous function. It is used primarily to implement
functional interfaces in a more readable way.
28. What is the difference between Serializable and Externalizable?
Page 1
Core Java Interview Questions and Answers
Serializable is a marker interface used for default serialization, whereas Externalizable gives the programmer
full control over the serialization process by implementing writeExternal() and readExternal() methods.
29. What is the difference between shallow copy and deep copy?
A shallow copy copies the references to the objects, while a deep copy creates a new copy of the object
along with copies of the objects it refers to.
30. What is the Java Collections Framework?
The Java Collections Framework is a set of classes and interfaces that implement commonly reusable
collection data structures such as lists, sets, and maps.
31. Sample Question 31
Sample Answer for question 31
32. Sample Question 32
Sample Answer for question 32
33. Sample Question 33
Sample Answer for question 33
34. Sample Question 34
Sample Answer for question 34
35. Sample Question 35
Sample Answer for question 35
36. Sample Question 36
Sample Answer for question 36
37. Sample Question 37
Page 2
Core Java Interview Questions and Answers
Sample Answer for question 37
38. Sample Question 38
Sample Answer for question 38
39. Sample Question 39
Sample Answer for question 39
40. Sample Question 40
Sample Answer for question 40
41. Sample Question 41
Sample Answer for question 41
42. Sample Question 42
Sample Answer for question 42
43. Sample Question 43
Sample Answer for question 43
44. Sample Question 44
Sample Answer for question 44
45. Sample Question 45
Sample Answer for question 45
46. Sample Question 46
Sample Answer for question 46
47. Sample Question 47
Sample Answer for question 47
Page 3
Core Java Interview Questions and Answers
48. Sample Question 48
Sample Answer for question 48
49. Sample Question 49
Sample Answer for question 49
50. Sample Question 50
Sample Answer for question 50
51. Sample Question 51
Sample Answer for question 51
52. Sample Question 52
Sample Answer for question 52
53. Sample Question 53
Sample Answer for question 53
54. Sample Question 54
Sample Answer for question 54
55. Sample Question 55
Sample Answer for question 55
56. Sample Question 56
Sample Answer for question 56
57. Sample Question 57
Sample Answer for question 57
58. Sample Question 58
Page 4
Core Java Interview Questions and Answers
Sample Answer for question 58
59. Sample Question 59
Sample Answer for question 59
60. Sample Question 60
Sample Answer for question 60
61. Sample Question 61
Sample Answer for question 61
62. Sample Question 62
Sample Answer for question 62
63. Sample Question 63
Sample Answer for question 63
64. Sample Question 64
Sample Answer for question 64
65. Sample Question 65
Sample Answer for question 65
66. Sample Question 66
Sample Answer for question 66
67. Sample Question 67
Sample Answer for question 67
68. Sample Question 68
Sample Answer for question 68
Page 5
Core Java Interview Questions and Answers
69. Sample Question 69
Sample Answer for question 69
70. Sample Question 70
Sample Answer for question 70
71. Sample Question 71
Sample Answer for question 71
72. Sample Question 72
Sample Answer for question 72
73. Sample Question 73
Sample Answer for question 73
74. Sample Question 74
Sample Answer for question 74
75. Sample Question 75
Sample Answer for question 75
76. Sample Question 76
Sample Answer for question 76
77. Sample Question 77
Sample Answer for question 77
78. Sample Question 78
Sample Answer for question 78
79. Sample Question 79
Page 6
Core Java Interview Questions and Answers
Sample Answer for question 79
80. Sample Question 80
Sample Answer for question 80
81. Sample Question 81
Sample Answer for question 81
82. Sample Question 82
Sample Answer for question 82
83. Sample Question 83
Sample Answer for question 83
84. Sample Question 84
Sample Answer for question 84
85. Sample Question 85
Sample Answer for question 85
86. Sample Question 86
Sample Answer for question 86
87. Sample Question 87
Sample Answer for question 87
88. Sample Question 88
Sample Answer for question 88
89. Sample Question 89
Sample Answer for question 89
Page 7
Core Java Interview Questions and Answers
90. Sample Question 90
Sample Answer for question 90
91. Sample Question 91
Sample Answer for question 91
92. Sample Question 92
Sample Answer for question 92
93. Sample Question 93
Sample Answer for question 93
94. Sample Question 94
Sample Answer for question 94
95. Sample Question 95
Sample Answer for question 95
96. Sample Question 96
Sample Answer for question 96
97. Sample Question 97
Sample Answer for question 97
98. Sample Question 98
Sample Answer for question 98
99. Sample Question 99
Sample Answer for question 99
100. Sample Question 100
Page 8
Core Java Interview Questions and Answers
Sample Answer for question 100
Page 9