Interview Questions:
1. What is method? With its classification.
2. Syntax with explaining each term.
3. Method Binding Process?
4. Method Overloading?
5. Execution process of Method.
6. What is return keyword?
7. Can we use return keyword in void? why?
8. Difference between return and return type?
9. What will happen if we try to write any code after return statement?
10. What is static keyword? And where are the static members stored?
[Link] can we access or call a static member in Different Class?
12. What is dot operator?
13. Can we use non-static variable in static method?
14. Can we use this and super keyword in static method? Why?
15. Process to segregate Source and class file.
16. Can we have same name of local variable and static variable? If yes, how the preference
is given?
17. Why do we use static initializers?
18. What is static block?
19. When does the static block executes?
20. How many times static block will execute?
21. How many static blocks can be there?
22. Can we execute static block without main method?
23. What is class loading process?
24. Why cannot we have more than 1 public class in single java file?
25. What is Driver Class?
26. Perm-Gen vs Meta Space?
27. What is OOPs?
28. What is Class & Object?
29. How do we create an Object?
30. What is the default value of non-primitive datatype?
31. What is non static variable/ object variable/ instance variable?
32. What is this keyword with purpose.
33. What is block or non-static block and how they get executed?
34. What is method chaining?
35. What is constructor? Why do we need Constructor?
36. Types of constructors?
37. What is Constructor Overloading?
38. Can we Override/Overload a Constructor?
39. What is Constructor Chaining?
40. How do we achieve Constructor chaining?
41. What is IDE?
42. What are packages? Advantages.
43. Which package in java is imported internally?
44. Principles of OOPs?
45. What/when/how/why Encapsulation?
46. What is data hiding? How do we achieve it?
47. What is HAS-A relationship?
48. What is Early instantiation and lazy instantiation?
49. Is-A relationship?
50. What is inheritance?
51. Types of inheritance?
52. What is extends keyword?
53. Which keyword is used to inherit Class and Class?
54. Which keyword is used to inherit Class and interface?
55. Which keyword is used to inherit Interface and Interface?
56. Levels of inheritance.
57. What is Diamond Problem with Solution?
58. What is Hybrid Inheritance?
59. What is super keyword? Can we print super keyword?
60. What is super call statement?
61. What is instanceof operator?
62. What is derived Typecasting? When do we perform non-primitive typecasting?
63. Why do we do upcasting and down casting?
64. When would we get ClassCastException?
65. What is Polymorphism? Types.
66. Difference between method overloading and overriding?
67. Rules of method Overloading/how do we achieve overloading?
68. Why does java not support operator overloading?
69. How do we achieve Runtime Polymorphism ?
70. How can we restrict making an Object of the class?
71. How can we create only one object of class?
72. What is Object class?
73. Which are the methods of the Object class?
74. What is the functionality of toString()?
75. What is the functionality of equals()?
76. What is the functionality of hashCode()?
77. When will you override the hashCode()?
78. What is native method?
79. Object class vs Objects class.
80. Difference between == and equals().
81. What is contract between hashCode and equals()?
82. When we override equals(), why it is recommended to override hashcode()?
83. What is use of getClass()?
84. What is Abstraction? How do we achieve it?
85. Abstract method vs interface?
86. Why does java not support Multiple Inheritance? Solution?
87. What is concrete method?
88. Can we make a static method as an abstract?
89. What is abstract keyword?
90. Can we create an object of abstract class? Why??
91. Can we put Constructor in abstract class?
92. Why do we need Interface?
93. In an Interface, what things are allowed?
94. Why is final static variable allowed in interface?
95. Why are concrete static methods allowed in interface?
96. Local variable vs global variable.
97. What is composition?
98. Explain main method?
99. What is getter and setter?
100. What is new keyword?
101. What is Functional Interface?
102. What is Exception and Exception handling?
103. Explain the hierarchy of Exception.
104. Why do we use static/non-static members?
105. What is Singleton Class? How to create it?
106. Why we do Constructor Chaining?
107. Why do we have multiple Constructor in a class?
108. Default value of a Object reference instance variable?
109. Can the keyword static be used with instance variable?
110. Difference between Error and Exception?
111. Difference Checked and unchecked exception.
112. How do we handle exception in java?
113. Can we use catch block without try block?
114. Can we only try block?
115. Can we only try and finally block?
116. When does the finally block don’t get executed?
117. What is mean by risky code?
118. Give some examples of Checked Exception and when we get that exception?
119. Give some examples of UnChecked Exception and when we get that exception?
120. Can we have multiple catch block? Why?
121. Finally vs final vs Finalize?
122. Throws vs throw?
123. Why exception is there in java?
124. Why do we want to declare an exception?
125. What are Access modifiers ? why do we need them?
126. Private vs Protected vs default vs public.
127. When cannot we inherit the constructor?
128. Ascending order of AM.
129. Can we make class as a private or protected?
130. Can a private member of a class be accessed by an inner (nested) class?
131. Can a private method in an interface exist?
132. If an interface field is declared int x = 10; what are its modifiers implicitly?
133. Can a private constructor prevent subclassing?
134. What can we make as final?
135. Can we make constructor final? Why or why not?
136. Can a final method be overloaded?
137. What happens if you don’t initialize a final variable?
138. Why is a final class often used with String?
139. Can you create a final array? Can its elements change?
140. If a class is final, can it still implement an interface?
141. What is sealed class?
142. Why do we need Wrapper class?
143. What is unboxing and boxing?
144. To perform unboxing which method do we have?
145. What is array with it benefits and limitations?
146. How to access or fetch the elements of Array?
147. Which access modifier allows access in same package but not in subclass of another
package?
148. What is the default value of an array of objects?
149. What is the default value of an array element?
150. Can you change the size of an array?
151. How are arrays stored in memory?
152. == vs equals()?
153. Why Strings are immutable?
154. What is String Pool area?
155. Difference between String s = “hi” and String s1 = new String(“hi”);
156. Memory Management of String?
157. Can we modify a String in Java?
158. What is String Pool? Why used?
159. Anagram and panagram.
160. String vs StringBuilder vs StringBuffer?
161. Is StringBuilder and StringBuffer mutuble?
162. Why do we need Collection framework?
163. What is collection, Explain its hierarchy ?
164. Explain the difference between Collection and Collections.
165. What is the difference between List, Set, and Map?
166. Why is Map not part of the Collection interface?
167. Difference between ArrayList and LinkedList.
168. Explain the Working of LinkedList.
169. Difference between HashSet, LinkedHashSet, and TreeSet.
170. Complexity of All DataStructure.
171. Difference between HashMap, LinkedHashMap, and TreeMap.
172. What is legacy class?
173. What is the difference between fail-fast and fail-safe iterators?
174. What is the difference between Iterator and ListIterator?
175. What is the difference between Comparable and Comparator?
176. When do we use comparable and comparator?
177. When do we go for arraylist and linkedlist?
178. Why are wrapper classes used in collections?
179. What is a generics in Java? Why is it used in collections?
180. How to iterator a collection?
181. When do we get NoSuchElementException?
182. When do we get ConcurrentModificationException? And How to Handle it?
183. Use For-each loop.
184. How to perform modification in iterator?
185. How to iterate a List collection in reverse order?
186. How does ArrayList work internally?
187. How does LinkedList work internally?
188. Why is LinkedList faster for insert/delete but slower for random access?
189. Can we store null in ArrayList? How many?
190. Why does ArrayList allow duplicates?
191. What is the initial capacity of ArrayList?
192. What is the initial capacity of LinkedList?
193. What happens when ArrayList exceeds its capacity?
194. How does HashSet store elements internally?
195. Why does HashSet not allow duplicates?
196. How does HashMap work internally?
197. What is hashing?
198. What is a hash collision? How is it resolved in HashMap?
199. What is the default load factor of HashMap?
200. What happens when two objects have the same hashcode in HashSet?
201. What are the rules for writing hashCode() and equals()?
202. How does TreeSet maintain sorting order?
203. Why does TreeSet not allow null?
204. Difference between HashSet and TreeSet performance.
205. What is rehashing?
206. On which DataStructure we can use ListIterator.
207. What is the difference between HashMap and Hashtable?
208. Why does HashMap allow one null key and multiple null values?
209. Why ConcurrentHashMap does not allow null?
210. How does LinkedHashMap maintain insertion order?
211. Difference between Queue and Deque?
212. Queue vs Stack.
213. How does PriorityQueue work internally?
214. Why PriorityQueue does not maintain insertion order?
215. What is BlockingQueue?
216. Difference between ArrayDeque and LinkedList as a Queue.
217. Explain fail-fast behavior in ArrayList iterator with example.
218. What is the difference between Stack and ArrayDeque?
219. Why HashSet uses HashMap internally?
220. What happens if a HashMap key’s hashCode() changes after insertion?
221. How to iterate a Map without using iterator?
222. Why TreeSet needs Comparable or Comparator?
223. How HashMap handles duplicate keys?
224. Difference between remove(), poll(), and peek() in Queue?
225. Why should we override both equals() and hashCode()?
226. What is structural modification in collections?
227. Sort a list of objects using Comparable & Comparator.
228. Convert List to Set & Set to List.
229. Convert Map to List of keys or values.
230. What is compareTo()?
231. How do we sort custom object in collection?
232. What does priorityQueue internally uses?
233. Characteristics of PQ?
234. Deque in java
235. What is HashTable with its internal working?
236. What is Hash Function?
237. What is hash Value?
238. What is hash collision?
239. What is hashcode and equals methods are not overridden in HashSet?
240. How are elements in HS compared?
241. LinkedHashSet?
242. When we do we use LinkedHashSet?
243. Internal lying data structure of LinkedHashSet?
244. Why TreeSet and PQ will not accept null?
245. Can u explain how the complexity of treeset is log of n?
246. When do we use comparator and camparable?
247. compareTo vs compare?
248. On what data structure in need comparable?
PROGRAMMING QUESTION: