java interview questions

200+ Java Interview Questions

Preparing for a Java Interview? Here is a list of 200+ Java Interview Questions that might help you ace that interview:

  1. Explain JVM, JRE and JDK?
  2. Explain public static void main(String args[])
  3. Why Java is platform independent?
  4. Why java is not 100% Object-oriented?
  5. What are wrapper classes?
  6. What are constructors in Java?
  7. What is singleton class and how can we make a class singleton?
  8. What is the difference between Array list and vector?
  9. What is the difference between equals() and == ?
  10. What are the differences between Heap and Stack Memory?
  11. What is Polymorphism?
  12. What is runtime polymorphism or dynamic method dispatch?
  13. What is the difference between abstract classes and interfaces?
  14. What is method overloading and method overriding?
  15. What is multiple inheritance? Is it supported by Java?
  16. What is association?
  17. What do you mean by aggregation?
  18. What is composition in Java?
  19. What is a servlet?
  20. What are the differences between Get and Post methods?
  21. What is Request Dispatcher?
  22. What are the differences between forward() method and sendRedirect() methods?
  23. What is the life-cycle of a servlet?
  24. How do cookies work in Servlets?
  25. What are the differences between ServletContext vs ServletConfig?
  26. What are the JDBC API components?
  27. What is the role of JDBC DriverManager class?
  28. What is JDBC Connection interface?
  29. What is the purpose of JDBC ResultSet interface?
  30. What is JDBC ResultSetMetaData interface?
  31. What is JDBC DatabaseMetaData interface?
  32. What do you mean by batch processing in JDBC?
  33. What is the difference between execute, executeQuery, executeUpdate?
  34. What is a Spring?
  35. Name the different modules of the Spring framework.
  36. List some of the important annotations in annotation-based Spring configuration.
  37. Explain Bean in Spring and List the different Scopes of Spring bean.
  38. Explain the role of DispatcherServlet and ContextLoaderListener.
  39. What are the differences between constructor injection and setter injection?
  40. What is autowiring in Spring? What are the autowiring modes?
  41. What are some of the important Spring annotations which you have used?
  42. How to integrate Spring and Hibernate Frameworks?
  43. What is Hibernate Framework?
  44. Explain Hibernate architecture?
  45. What are the differences between get and load methods?
  46. What are the advantages of Hibernate over JDBC?
  47. What are the life-cycle methods for a jsp?
  48. What are the JSP implicit objects?
  49. What are the differences between include directive and include action?
  50. How to disable caching on back button of the browser?
  51. What are the different tags provided in JSTL?
  52. How to disable session in JSP?
  53. How to delete a Cookie in a JSP?
  54. Explain the jspDestroy() method.
  55. How is JSP better than Servlet technology?
  56. Why should we not configure JSP standard tags in web.xml?
  57. What is difference between Error and Exception?
  58. How can you handle Java exceptions?
  59. What are the differences between Checked Exception and Unchecked Exception?
  60. What purpose does the keywords final, finally, and finalize fulfill?
  61. What are the differences between throw and throws?
  62. What is exception hierarchy in java?
  63. How to create a custom Exception?
  64. What are the important methods of Java Exception Class?
  65. What are the differences between processes and threads?
  66. What is a finally block? Is there a case when finally will not execute?
  67. What is synchronization?
  68. Can we write multiple catch blocks under single try block?
  69. What are the important methods of Java Exception Class?
  70. What is difference between JDK,JRE and JVM?
  71. How many types of memory areas are allocated by JVM?
  72. What is JIT compiler?
  73. What is platform?
  74. What is the main difference between Java platform and other platforms?
  75. What gives Java its ‘write once and run anywhere’ nature?
  76. What is classloader?
  77. Is Empty .java file name a valid source file name?
  78. Is delete, next, main, exit or null keyword in java?
  79. If I don’t provide any arguments on the command line, then the String array of Main method will be empty or null?
  80. What if I write static public void instead of public static void?
  81. What is the default value of the local variables?
  82. What is the difference between an object-oriented programming language and object-based programming language?
  83. What will be the initial value of an object reference which is defined as an instance variable?
  84. What is constructor?
  85. What is the purpose of default constructor?
  86. Does constructor return any value?
  87. Is constructor inherited?
  88. Can you make a constructor final?
  89. What is static variable?
  90. What is static method?
  91. Why main method is static?
  92. What is static block?
  93. Can we execute a program without main() method?
  94. What if the static modifier is removed from the signature of the main method?
  95. What is difference between static (class) method and instance method?
  96. What is this in java?
  97. What is Inheritance?
  98. Which class is the superclass for every class.
  99. Why multiple inheritance is not supported in java?
  100. What is composition?
  101. What is difference between aggregation and composition?
  102. Why Java does not support pointers?
  103. What is super in java?
  104. Can you use this() and super() both in a constructor?
  105. What is object cloning?
  106. What is method overloading?
  107. Why method overloading is not possible by changing the return type in java?
  108. Can we overload main() method?
  109. What is method overriding:
  110. Can we override static method?
  111. Why we cannot override static method?
  112. Can we override the overloaded method?
  113. Difference between method Overloading and Overriding.
  114. Can you have virtual functions in Java?
  115. What is covariant return type?
  116. What is final variable?
  117. What is final method?
  118. What is final class?
  119. What is blank final variable?
  120. Can we intialize blank final variable?
  121. Can you declare the main method as final?
  122. What is Runtime Polymorphism?
  123. Can you achieve Runtime Polymorphism by data members?
  124. What is the difference between static binding and dynamic binding?
  125. What is abstraction?
  126. What is the difference between abstraction and encapsulation?
  127. What is abstract class?
  128. Can there be any abstract method without abstract class?
  129. Can you use abstract and final both with a method?
  130. Is it possible to instantiate the abstract class?
  131. What is interface?
  132. Can you declare an interface method static?
  133. Can an Interface be final?
  134. What is marker interface?
  135. What is difference between abstract class and interface?
  136. Can we define private and protected modifiers for variables in interfaces?
  137. When can an object reference be cast to an interface reference?
  138. What is a package?
  139. Do I need to import java.lang package any time? Why ?
  140. Can I import same package/class twice? Will the JVM load the package twice at runtime?
  141. What is static import ?
  142. What is Exception Handling?
  143. What is difference between Checked Exception and Unchecked Exception?
  144. Is it necessary that each try block must be followed by a catch block?
  145. What is finally block?
  146. Can finally block be used without catch?
  147. Is there any case when finally will not be executed?
  148. What is difference between throw and throws?
  149. Can an exception be rethrown?
  150. Can subclass overriding method declare an exception if parent class method doesn’t throw an exception ?
  151. What is exception propagation ?
  152. What is the meaning of immutable in terms of String?
  153. Why string objects are immutable in java?
  154. How many ways we can create the string object?
  155. How many objects will be created in the following code?
  156. Why java uses the concept of string literal?
  157. How many objects will be created in the following code?
  158. What is the basic difference between string and stringbuffer object?
  159. What is the difference between StringBuffer and StringBuilder ?
  160. How can we create immutable class in java ?
  161. What is the purpose of toString() method in java ?
  162. What is nested class?
  163. Is there any difference between nested classes and inner classes?
  164. Can we access the non-final local variable, inside the local inner class?
  165. What is nested interface ?
  166. Can a class have an interface?
  167. Can an Interface have a class?
  168. What is Garbage Collection?
  169. What is gc()?
  170. What is the purpose of finalize() method?
  171. Can an unrefrenced objects be refrenced again?
  172. What kind of thread is the Garbage collector thread?
  173. What is difference between final, finally and finalize?
  174. What is the purpose of the Runtime class?
  175. How will you invoke any external process in Java?
  176. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
  177. What an I/O filter?
  178. What is serialization?
  179. What is Deserialization?
  180. What is transient keyword?
  181. What is Externalizable?
  182. What is the difference between Serializalble and Externalizable interface?
  183. How do I convert a numeric IP address like into a hostname like
  184. What is reflection?
  185. Can you access the private method from outside the class?
  186. What are wrapper classes?
  187. What is a native method?
  188. What is the purpose of the System class?
  189. What comes to mind when someone mentions a shallow copy in Java?
  190. What is singleton class?
  191. Which containers use a border layout as their default layout?
  192. Which containers use a FlowLayout as their default layout?
  193. What are peerless components?
  194. Is the difference between a Scrollbar and a ScrollPane?
  195. What is a lightweight component?
  196. What is a heavyweight component?
  197. What is an applet?
  198. Can you write a Java class that could be used both as an applet as well as an application?
  199. What is Locale?
  200. How will you load a specific locale?
  201. What is a JavaBean?
  202. Can RMI and Corba based applications interact?

Did these help you? Let us know in comments!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.