Core Java Interview Questions and Answers
Difficulty Level: AllIntermediateExpert
Ques 1. When should I use abstract methods?
Ques 2. Why use an abstract class instead of an interface?
Ques 3. If an object is garbage collected, can it become reachable again?
Ques 4. What is the purpose of finalization?
Ques 5. Does garbage collection guarantee that a program will not run out of memory?
Ques 6. an object's finalize() method be invoked while it is reachable?
Ques 7. What kind of thread is the Garbage collector thread?
Ques 8. Explain Garbage collection mechanism in Java?
Ques 9. What is FileOutputStream in java?
Ques 10. What is difference between String and StringTokenizer?
Ques 11. What is Constructor in Java?
Ques 12. What is this() keyword in core java and when should we use this() in core java?
Ques 13. What is java.lang package in Core java?
Ques 14. What is java.util package in Core Java?
Ques 15. What is java.io package in Core Java?
Ques 16. What is data encapsulation?
Ques 17. What is java.math package in Core Java?
Ques 18. What is polymorphism in Java? Method overloading or overriding?
Ques 19. What is multithreading in Java?
Ques 20. What is keyword in Core Java?
Ques 21. What is identifier in java?
Ques 22. What is literals in core java?
Ques 23. What is the argument type of a program's main() method?
Ques 24. Java says "write once, run anywhere". What are some ways this isn't quite true?
Ques 25. What is the return type of a program's main() method?
Ques 26. What gives java it's "write once and run anywhere" nature?
Ques 27. What is the purpose of the System class?
Ques 28. What's the difference between J2SDK 1.5 and J2SDK 5.0?
Ques 29. What is the purpose of Void class?
Ques 30. What are the implicit packages that need not get imported into a class file?
Ques 31. What do you mean by a Classloader?
Ques 32. Difference between JRE/JVM/JDK/OpenJDK?
Ques 33. What is your platform's default character encoding?
Ques 34. Is JVM a compiler or an interpreter?
Ques 35. What is the purpose of assert keyword used in JDK1.4.x?
Ques 36. What is the advantage of OOP?
Ques 37. What are the methods in Object?
Ques 38. Which class should you use to obtain design information about an object?
Ques 39. What are the main differences between Java and C++?
Ques 40. If you're overriding the method equals() of an object, which other method you might also consider?
Ques 41. Can you instantiate the Math class?
Ques 42. What's the difference between == and equals method?
Ques 43. What is the volatile modifier for?
Ques 44. Is null a keyword?
Ques 45. Which characters may be used as the second character of an identifier,but not as the first character of an identifier?
Ques 46. Is 'abc' a primitive value?
Ques 47. What restrictions are placed on the values of each case of a switch statement?
Ques 48. What is the difference between a field variable and a local variable?
Ques 49. Are true and false keywords?
Ques 50. Is sizeof a keyword?
Ques 51. What is the difference between the Boolean & operator and the && operator?
Ques 52. What is the difference between a break statement and a continue statement?
Ques 53. Name the eight primitive Java types.
Ques 54. Does Java have "goto"?
Ques 55. Explain the usage of the keyword transient?
Ques 56. What is the difference between constructors and other methods in core java?
Ques 57. What is the range of the char type?
Ques 58. What is the difference between a while statement and a do statement?
Ques 59. What are the legal operands of the instanceof operator?
Ques 60. What can go wrong if you replace && with & in the following code:
Ques 61. What's the difference between a queue and a stack?
Ques 62. What does the "final" keyword mean in front of a variable? A method? A class?
Ques 63. Is the ternary operator written x : y ? z or x ? y : z ?
Ques 64. How do you know if an explicit object casting is needed?
Ques 65. What are native methods? How do you use them?
Ques 66. What is the use of transient?
Ques 67. What is Externalizable?
Ques 68. What modifiers may be used with an inner class that is a member of an outer class?
Ques 69. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
Ques 70. What is the difference between the >> and >>> operators?
Ques 71. Can a for statement loop indefinitely?
Ques 72. What is the % operator?
Ques 73. What are abstract classes, abstract methods?
Ques 74. What does the "abstract" keyword mean in front of a method? A class?
Ques 75. What is the purpose of abstract class?
Ques 76. How to define an Abstract class?
Ques 77. Can there be an abstract class with no abstract methods in it?
Ques 78. What does it mean that a method or class is abstract?
Ques 79. What is an abstract method?
Ques 80. What are interfaces?
Ques 81. What is similarities/difference between an Abstract class and Interface?
Ques 82. How to define an Interface in Java ?
Ques 83. Can an Interface have an inner class?
Ques 84. What modifiers are allowed for methods in an Interface?
Ques 85. What must a class do to implement an interface?
Ques 86. What are the differences between an interface and an abstract class?
Ques 87. What is the difference between interface and abstract class?
Ques 88. Access specifiers: "public", "protected", "private", nothing?
Ques 89. Can a abstract method have the static qualifier?
Ques 90. What are the different types of qualifier and what is the default qualifier?
Ques 91. Can an Interface be final?
Ques 92. Can we define private and protected modifiers for variables in interfaces?
Ques 93. What is a local, member and a class variable?
Ques 94. What does it mean that a method or field is 'static'?
Ques 95. What modifiers may be used with an interface declaration?
Ques 96. If a method is declared as protected, where may the method be accessed?
Ques 97. What does it mean that a class or member is final?
Ques 98. What is a transient variable?
Ques 99. What do you understand by private, protected and public?
Ques 100. What happens to a static var that is defined within a method of a class ?
Ques 101. What does the 'final'?? keyword mean in front of a variable? A method? A class?
Ques 102. What is the final keyword denotes?
Ques 103. If a variable is declared as private, where may the variable be accessed?
Ques 104. If a class is declared without any access modifiers, where may the class be accessed?
Ques 105. What is a native method?
Ques 106. How can you achieve Multiple Inheritance in Java?
Ques 107. Does Java have multiple inheritance?
Ques 108. What is the super class of Hashtable?
Ques 109. Is a class a subclass of itself?
Ques 110. How are this() and super() used with constructors?
Ques 111. What is the difference between instanceof and isInstance?
Ques 112. Which class is extended by all other classes?
Ques 113. Does a class inherit the constructors of its superclass?
Ques 114. How would you make a copy of an entire Java object with its state?
Ques 115. How can a subclass call a method or a constructor defined in a superclass?
Ques 116. When does the compiler supply a default constructor for a class?
Ques 117. What is composition?
Ques 118. What is aggregation?
Ques 119. Can a method be overloaded based on different return type but same argument type ?
Ques 120. What restrictions are placed on method overloading?
Ques 121. How could Java classes direct program messages to the system console, but error messages, say to a file?
Ques 122. Which class is the wait() method defined in?
Ques 123. What is a thread?
Ques 124. What are the ways in which you can instantiate a thread?
Ques 125. What are the states of a thread?
Ques 126. What are the different identifier states of a Thread?
Ques 127. What is the difference between preemptive scheduling and time slicing?
Ques 128. Whats the difference between notify() and notifyAll()?
Ques 129. What state does a thread enter when it terminates its processing?
Ques 130. Why would you use a synchronized block vs. synchronized method?
Ques 131. What are the differences between the methods sleep() and wait()?
Ques 132. How can you force garbage collection?
Ques 133. What comes to mind when you hear about a young generation in Java?
Ques 134. How does exception handling work in Java?
Ques 135. Does Java have destructors?
Ques 136. What is the catch or declare rule for method declarations?
Ques 137. Can an exception be rethrown?
Ques 138. What class of exceptions are generated by the Java run-time system?
Ques 139. What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?
Ques 140. Does garbage collection guarantee that a program will not run out of memory?
Ques 141. Can an object's finalize() method be invoked while it is reachable?
Ques 142. What is the purpose of garbage collection?
Ques 143. What kind of thread is the Garbage collector thread?
Ques 144. What is the base class for Error and Exception?
Ques 145. What is the purpose of finalization?
Ques 146. What is the purpose of the finally clause of a try-catch-finally statement?
Ques 147. Can an object be garbage collected while it is still reachable?
Ques 148. What classes of exceptions may be caught by a catch clause?
Ques 149. If a class is located in a package, what do you need to change in the OS environment to be able to use it?
Ques 150. What restrictions are placed on the location of a package statement within a source code file?
Ques 151. Which package is always imported by default?
Ques 152. What is a package?
Ques 153. Explain the usage of Java packages.
Ques 154. You are planning to do an indexed search in a list of objects. Which of the two Java collections should you use: ArrayList or LinkedList?
Ques 155. What is the difference between a Vector and an Array. Discuss the advantages and disadvantages of both?
Ques 156. What is Collection API ?
Ques 157. Is Iterator a Class or Interface? What is its use?
Ques 158. What is the major difference between LinkedList and ArrayList?
Ques 159. What is the main difference between a Vector and an ArrayList?
Ques 160. What is Locale?
Ques 161. How will you load a specific locale?
Ques 162. What is singleton?
Ques 163. What is the difference between StringBuffer and String class?
Ques 164. What is the eligibility for a object to get cloned?
Ques 165. What are wrapped classes?
Ques 166. What is casting?
Ques 167. What are E and PI?
Ques 168. What happens when you add a double value to a String?
Ques 169. Why can't I say just abs() or sin() instead of Math.abs() and Math.sin()?
Ques 170. How are Observer and Observable used?
Ques 171. How does Java handle integer overflows and underflows?
Ques 172. To what value is a variable of the String type automatically initialized?
Ques 173. What is the range of the short type?
Ques 174. What is Downcasting ?
Ques 175. How many static init can you have ?
Ques 176. What is mutable object and immutable object?
Ques 177. What is the basic difference between string and stringbuffer object?
Ques 178. What is the byte range?
Ques 179. Can a double value be cast to a byte?
Ques 180. Can a Byte object be cast to a double value?
Ques 181. How is rounding performed under integer division?
Ques 182. What would you use to compare two String variables - the operator == or the method equals()?
Ques 183. Which non-Unicode letter characters may be used as the first character of an identifier?
Ques 184. What is a hashCode?
Ques 185. What modifiers can be used with a local inner class?
Ques 186. Why are the methods of the Math class static?
Ques 187. What is inner class?
Ques 188. What is the use of serializable?
Ques 189. What class allows you to read objects directly from a stream?
Ques 190. What is the difference between the File and RandomAccessFile classes?
Ques 191. What interface must an object implement before it can be written to a stream as an object?
Ques 192. What value does readLine() return when it has reached the end of a file?
Ques 193. What is the purpose of the File class?
Ques 194. What is a socket?
Ques 195. How can my application get to know when a HttpSession is removed?
Ques 196. What is the SwingUtilities.invokeLater(Runnable) method for?
Ques 197. What is a lightweight component?
Ques 198. What is a heavyweight component?
Ques 199. What is the difference between lightweight and heavyweight component?
Ques 200. Which containers use a border layout as their default layout?
Ques 201. What are java beans?
Ques 202. What is DriverManager?
Ques 203. What is Class.forName() does and how it is useful?
Ques 204. What do you mean by RMI and how it is useful?
Ques 205. What is the protocol used by RMI?
Ques 206. What is the use of PreparedStatement?
Ques 207. What is callable statement? Tell me the way to get the callable statement?