Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store

Exams Attended

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core Java Interview Questions and Answers

  Difficulty Level: AllBeginnerIntermediateExperienced/Expert

Ques 1. What is Constructor in Java?

Ques 2. What is java.util package in Core Java?

Ques 3. What is difference between String and StringTokenizer?

Ques 4. What is the argument type of a program's main() method?

Ques 5. What is this() keyword in core java and when should we use this() in core java?

Ques 6. Java says "write once, run anywhere". What are some ways this isn't quite true?

Ques 7. What is phantom memory?

Ques 8. What is the return type of a program's main() method?

Ques 9. What gives java it's "write once and run anywhere" nature?

Ques 10. What is java.lang package in Core java?

Ques 11. What is the purpose of the System class?

Ques 12. What is java.io package in Core Java?

Ques 13. What is data encapsulation?

Ques 14. What is java.math package in Core Java?

Ques 15. What's the difference between J2SDK 1.5 and J2SDK 5.0?

Ques 16. How can I swap two variables without using a third variable?

Ques 17. What is the purpose of Void class?

Ques 18. What is Cloneable Interface in Core Java?

Ques 19. Explain working of Java Virtual Machine (JVM)?

Ques 20. What is abstraction?

Ques 21. What are the implicit packages that need not get imported into a class file?

Ques 22. String vs StringBuffer vs StringBuilder in Java

Ques 23. What do you mean by a Classloader?

Ques 24. Difference between JRE/JVM/JDK/OpenJDK?

Ques 25. Why String is immutable or final in Java?

Ques 26. What is your platform's default character encoding?

Ques 27. What is the difference amongst JVM Spec, JVM Implementation, JVM Runtime ?

Ques 28. What is JIT and its use?

Ques 29. Is JVM a compiler or an interpreter?

Ques 30. What is the purpose of assert keyword used in JDK1.4.x?

Ques 31. How will you get the platform dependent values like line separator, path separator, etc., ?

Ques 32. What is the advantage of OOP?

Ques 33. What are the methods in Object?

Ques 34. Which class should you use to obtain design information about an object?

Ques 35. What are the main differences between Java and C++?

Ques 36. If you're overriding the method equals() of an object, which other method you might also consider?

Ques 37. What comes to mind when someone mentions a shallow copy and deep copy in Java?

Ques 38. Can you instantiate the Math class?

Ques 39. What's the difference between == and equals method?

Ques 40. What is the volatile modifier for?

Ques 41. Is null a keyword?

Ques 42. Which characters may be used as the second character of an identifier,but not as the first character of an identifier?

Ques 43. Is 'abc' a primitive value?

Ques 44. What restrictions are placed on the values of each case of a switch statement?

Ques 45. What is the difference between a field variable and a local variable?

Ques 46. Are true and false keywords?

Ques 47. Why are there no global variables in Java?

Ques 48. Is sizeof a keyword?

Ques 49. What is the difference between the Boolean & operator and the && operator?

Ques 50. Which Java operator is right associative?

Ques 51. What is the difference between a break statement and a continue statement?

Ques 52. Name the eight primitive Java types.

Ques 53. Describe what happens when an object is created in Java?

Ques 54. In Java, you can create a String object as below : String str = "abc"; & String str = new String("abc");  Why cant a button object be created as : Button bt = "abc"? Why is it compulsory to create a button object as: Button bt = new Button("abc"); Why this is not compulsory in String's case?

Ques 55. Does Java have "goto"?

Ques 56. Explain the usage of the keyword transient?

Ques 57. What is the difference between constructors and other methods in core java?

Ques 58. What is the range of the char type?

Ques 59. What is the difference between a while statement and a do statement?

Ques 60. What are the legal operands of the instanceof operator?

Ques 61. Can you call one constructor from another if a class has multiple constructors?

Ques 62. What can go wrong if you replace && with & in the following code:

Ques 63. What's the difference between a queue and a stack?

Ques 64. What does the "final" keyword mean in front of a variable? A method? A class?

Ques 65. Is the ternary operator written x : y ? z or x ? y : z ?

Ques 66. How do you know if an explicit object casting is needed?

Ques 67. What are native methods? How do you use them?

Ques 68. What is the use of transient?

Ques 69. What is Externalizable?

Ques 70. What modifiers may be used with an inner class that is a member of an outer class?

Ques 71. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?

Ques 72. What is the difference between the >> and >>> operators?

Ques 73. Can a for statement loop indefinitely?

Ques 74. How are commas used in the intialization and iteration parts of a for statement?

Ques 75. What is the % operator?

Ques 76. What are abstract classes, abstract methods?

Ques 77. What does the "abstract" keyword mean in front of a method? A class?

Ques 78. What is the purpose of abstract class?

Ques 79. How to define an Abstract class?

Ques 80. Can there be an abstract class with no abstract methods in it?

Ques 81. What does it mean that a method or class is abstract?

Ques 82. What is an abstract method?

Ques 83. You can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that declares the same methods. So can you use abstract classes instead of interfaces?

Ques 84. What are interfaces?

Ques 85. What is similarities/difference between an Abstract class and Interface?

Ques 86. How to define an Interface in Java ?

Ques 87. How many methods in the Serializable interface?

Ques 88. How many methods in the Externalizable interface?

Ques 89. What is the difference between Serializalble and Externalizable interface?

Ques 90. Can an Interface have an inner class?

Ques 91. What modifiers are allowed for methods in an Interface?

Ques 92. What must a class do to implement an interface?

Ques 93. What are the differences between an interface and an abstract class?

Ques 94. What is the difference between interface and abstract class?

Ques 95. Access specifiers: "public", "protected", "private", nothing?

Ques 96. Can a abstract method have the static qualifier?

Ques 97. What are the different types of qualifier and what is the default qualifier?

Ques 98. Can an Interface be final?

Ques 99. Can we define private and protected modifiers for variables in interfaces?

Ques 100. What is a local, member and a class variable?

Ques 101. What does it mean that a method or field is 'static'?

Ques 102. What modifiers may be used with an interface declaration?

Ques 103. If a method is declared as protected, where may the method be accessed?

Ques 104. What does it mean that a class or member is final?

Ques 105. What is a transient variable?

Ques 106. What do you understand by private, protected and public?

Ques 107. What happens to a static var that is defined within a method of a class ?

Ques 108. What does the 'final'?? keyword mean in front of a variable? A method? A class?

Ques 109. What is the final keyword denotes?

Ques 110. What is the difference between a static and a non-static inner class?

Ques 111. If a variable is declared as private, where may the variable be accessed?

Ques 112. If a class is declared without any access modifiers, where may the class be accessed?

Ques 113. What is a native method?

Ques 114. What is reflection?

Ques 115. How can you achieve Multiple Inheritance in Java?

Ques 116. Does Java have multiple inheritance?

Ques 117. What is the super class of Hashtable?

Ques 118. What are some alternatives to inheritance?

Ques 119. Is a class a subclass of itself?

Ques 120. How are this() and super() used with constructors?

Ques 121. What is the difference between instanceof and isInstance?

Ques 122. When can an object reference be cast to an interface reference?

Ques 123. Which class is extended by all other classes?

Ques 124. Does a class inherit the constructors of its superclass?

Ques 125. How would you make a copy of an entire Java object with its state?

Ques 126. How can a subclass call a method or a constructor defined in a superclass?

Ques 127. Can an anonymous class be declared as implementing an interface and extending a class?

Ques 128. When does the compiler supply a default constructor for a class?

Ques 129. What is composition?

Ques 130. What is aggregation?

Ques 131. Why isn't there operator overloading?

Ques 132. Can a method be overloaded based on different return type but same argument type ?

Ques 133. What restrictions are placed on method overloading?

Ques 134. How could Java classes direct program messages to the system console, but error messages, say to a file?

Ques 135. What does the keyword "synchronize" mean in java. When do you use it? What are the disadvantages of synchronization?

Ques 136. What synchronization constructs does Java provide? How do they work?

Ques 137. Do I need to use synchronized on setValue(int)?

Ques 138. Which class is the wait() method defined in?

Ques 139. Which class is the wait() method defined in? I get incompatible return type for my thread getState( ) method!

Ques 140. What is a working thread?

Ques 141. What is a green thread?

Ques 142. What is a thread?

Ques 143. What is the algorithm used in Thread scheduling?

Ques 144. What are the different level lockings using the synchronization keyword?

Ques 145. What are the ways in which you can instantiate a thread?

Ques 146. What are the states of a thread?

Ques 147. What are the threads will start, when you start the java program?

Ques 148. What are the different identifier states of a Thread?

Ques 149. What is synchronization and why is it important?

Ques 150. What is the difference between preemptive scheduling and time slicing?

Ques 151. Whats the difference between notify() and notifyAll()?

Ques 152. Can a lock be acquired on a class?

Ques 153. What state does a thread enter when it terminates its processing?

Ques 154. What is a task's priority and how is it used in scheduling?

Ques 155. What is a daemon thread?

Ques 156. What are the approaches that you will follow for making a program very efficient?

Ques 157. What is an object's lock and which object's have locks?

Ques 158. Why would you use a synchronized block vs. synchronized method?

Ques 159. What are the differences between the methods sleep() and wait()?

Ques 160. There are two classes: A and B. The class B need to inform a class A when some important event has happened. What Java technique would you use to implement it?

Ques 161. How can you force garbage collection?

Ques 162. What comes to mind when you hear about a young generation in Java?

Ques 163. How does exception handling work in Java?

Ques 164. Does Java have destructors?

Ques 165. What is the catch or declare rule for method declarations?

Ques 166. Can an exception be rethrown?

Ques 167. What class of exceptions are generated by the Java run-time system?

Ques 168. What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?

Ques 169. If an object is garbage collected, can it become reachable again?

Ques 170. Does garbage collection guarantee that a program will not run out of memory?

Ques 171. Can an object's finalize() method be invoked while it is reachable?

Ques 172. What is the purpose of garbage collection?

Ques 173. What is garbage collection? What is the process that is responsible for doing that in java?

Ques 174. What kind of thread is the Garbage collector thread?

Ques 175. What is the finalize method do?

Ques 176. What is the base class for Error and Exception?

Ques 177. What is the implementation of destroy method in java.. is it native or java code?

Ques 178. What is the purpose of finalization?

Ques 179. How many times may an object's finalize() method be invoked by the garbage collector?

Ques 180. What is the purpose of the finally clause of a try-catch-finally statement?

Ques 181. Can an object be garbage collected while it is still reachable?

Ques 182. What classes of exceptions may be caught by a catch clause?

Ques 183. How can you minimize the need of garbage collection and make the memory use more effective?

Ques 184. Does it matter in what order catch statements for FileNotFoundException and IOExceptipon are written?

Ques 185. 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 186. What restrictions are placed on the location of a package statement within a source code file?

Ques 187. Which package is always imported by default?

Ques 188. What is a package?

Ques 189. Explain the usage of Java packages.

Ques 190. 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 191. 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 192. What is the difference between a Vector and an Array. Discuss the advantages and disadvantages of both?

Ques 193. What interface do you implement to do the sorting?

Ques 194. What is Collection API ?

Ques 195. Is Iterator a Class or Interface? What is its use?

Ques 196. What is the significance of ListIterator?

Ques 197. What is the major difference between LinkedList and ArrayList?

Ques 198. What is the main difference between a Vector and an ArrayList?

Ques 199. What is hash-collision in Hashtable and how it is handled in Java?

Ques 200. What is Locale?

Ques 201. How will you load a specific locale?

Ques 202. What is singleton?

Ques 203. Can an inner class declared inside of a method access local variables of this method?

Ques 204. What is the difference between StringBuffer and String class?

Ques 205. What is the eligibility for a object to get cloned?

Ques 206. What are wrapped classes?

Ques 207. What is casting?

Ques 208. What are E and PI?

Ques 209. What happens when you add a double value to a String?

Ques 210. Why can't I say just abs() or sin() instead of Math.abs() and Math.sin()?

Ques 211. How are Observer and Observable used?

Ques 212. How does Java handle integer overflows and underflows?

Ques 213. To what value is a variable of the String type automatically initialized?

Ques 214. What is the range of the short type?

Ques 215. What is Downcasting ?

Ques 216. How many static init can you have ?

Ques 217. What is mutable object and immutable object?

Ques 218. What is the basic difference between string and stringbuffer object?

Ques 219. What is the byte range?

Ques 220. Can a double value be cast to a byte?

Ques 221. Can a Byte object be cast to a double value?

Ques 222. How is rounding performed under integer division?

Ques 223. What would you use to compare two String variables - the operator == or the method equals()?

Ques 224. Which non-Unicode letter characters may be used as the first character of an identifier?

Ques 225. What is a hashCode?

Ques 226. What are order of precedence and associativity, and how are they used?

Ques 227. What modifiers can be used with a local inner class?

Ques 228. Why are the methods of the Math class static?

Ques 229. When you think about optimization, what is the best way to findout the time/memory consuming process?

Ques 230. What is nested class?

Ques 231. What is inner class?

Ques 232. What is the use of serializable?

Ques 233. Why do threads block on I/O?

Ques 234. What class allows you to read objects directly from a stream?

Ques 235. What an I/O filter?

Ques 236. What is the difference between the File and RandomAccessFile classes?

Ques 237. What interface must an object implement before it can be written to a stream as an object?

Ques 238. What value does readLine() return when it has reached the end of a file?

Ques 239. What value does read() return when it has reached the end of a file?

Ques 240. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?

Ques 241. What is the purpose of the File class?

Ques 242. What is a socket?

Ques 243. How do I convert a numeric IP address like 192.18.97.39 into a hostname like java.sun.com?

Ques 244. How can my application get to know when a HttpSession is removed?

Ques 245. How will you invoke any external process in Java?

Ques 246. What is skeleton and stub? what is the purpose of those?

Ques 247. What is the SwingUtilities.invokeLater(Runnable) method for?

Ques 248. What is a lightweight component?

Ques 249. What is a heavyweight component?

Ques 250. What is the difference between lightweight and heavyweight component?

Ques 251. Which containers use a border layout as their default layout?

Ques 252. Can you write a Java class that could be used both as an applet as well as an application?

Ques 253. What is the advantage of the event-delegation model over the earlier event-inheritance model?

Ques 254. What are java beans?

Ques 255. What is a DatabaseMetaData?

Ques 256. What is DriverManager?

Ques 257. What is Class.forName() does and how it is useful?

Ques 258. What do you mean by RMI and how it is useful?

Ques 259. What is the protocol used by RMI?

Ques 260. What is the use of PreparedStatement?

Ques 261. What is callable statement? Tell me the way to get the callable statement?

Ques 262. In a statement, I am executing a batch. What is the result of the execution?

Ques 263. When should I use abstract methods?

Ques 264. Why use an abstract class instead of an interface?

Ques 265. In which case, do we need abstract classes with no abstract methods?

Ques 266. What's the use of concrete methods in abstract classes?

Ques 267. If an object is garbage collected, can it become reachable again?

Ques 268. What is the purpose of finalization?

Ques 269. Does garbage collection guarantee that a program will not run out of memory?

Ques 270. an object's finalize() method be invoked while it is reachable?

Ques 271. What kind of thread is the Garbage collector thread?

Ques 272. Explain Garbage collection mechanism in Java?

Ques 273. What is FileOutputStream in java?

Ques 274. Can a method be static and synchronized?

Ques 275. Does JVM maintain a cache by itself? Does the JVM allocate objects in heap? Is this the OS heap or the heap maintained by the JVM? Why?

Ques 276. What is reflection API? How are they implemented?

Ques 277. What is dead lock in thread?

Ques 278. When is static variable loaded? Is it at compile time or runtime? When exactly a static block is loaded in Java?

Ques 279. Difference between wait, notify and notifyAll in Core Java.

Ques 280. What is thread pool in java?

Ques 281. What is concurrency in java?

Ques 282. What is reason of NoClassDefFoundError in Java?

Ques 283. How to resolve NoClassDefFoundError?

Ques 284. Difference between ClassNotFoundException and NoClassDefFoundError in Java?

Ques 285. What is java.lang.OutOfMemoryError in Java?

Ques 286. Types of OutOfMemoryError in Java.

Ques 287. Difference between "java.lang.OutOfMemoryError: Java heap space" and "java.lang.OutOfMemoryError: PermGen space"

Ques 288. How HashMap works in Java?

Ques 289. What is the difference between Synchronized Collection classes and Concurrent Collection Classes ? When to use what ?

Ques 290. How to use Comparator and Comparable in Java? With example.

Ques 291. What is polymorphism in Java? Method overloading or overriding?

Ques 292. What is Encapsulation in Java and OOPS with Example?

Ques 293. Difference between Thread and Runnable interface in Java?

Ques 294. Difference between Wait and Sleep , Yield in Java

Ques 295. Difference between Vector and ArrayList in Java

Ques 296. What is Dictionary Class in Java?

Ques 297. What is Reference Handler Thread in Java?

Ques 298. What is Main thread in Java?

Ques 299. What is Signal Dispatcher thread in Java?

Ques 300. What is multithreading in Java?

Ques 301. What is keyword in Core Java?

Ques 302. What is identifier in java?

Ques 303. What is Checked Exception and its use in java?

Ques 304. What is Unchecked Exception in java?

Ques 305. What is Anonymous (inner) Class in java?

Ques 306. What is literals in core java?

©2020 WithoutBook