Without Book Interview Questions and Answers | Online Test | Moct Test
Download Android App in your Android Device from Google Play Store
- Search for "Withoutbook Practice Exam Test" in Mobile/Tablet Play Store
Institute Training Search by Name or Email

Exams Attended

Make Homepage

Bookmark this page

Subscribe Email Address

Core Java Interview Questions and Answers

  Difficulty Level: AllBeginnerIntermediateExpert

Ques 1. When should I use abstract methods?

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

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

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

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

Ques 6. What is the purpose of finalization?

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

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

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

Ques 10. Explain Garbage collection mechanism in Java?

Ques 11. What is FileOutputStream in java?

Ques 12. What is difference between String and StringTokenizer?

Ques 13. What is Constructor in Java?

Ques 14. Can a method be static and synchronized?

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

Ques 16. What is phantom memory?

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

Ques 18. 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 19. What is java.util package in Core Java?

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

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

Ques 22. What is data encapsulation?

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

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

Ques 25. What is Cloneable Interface in Core Java?

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

Ques 27. What is dead lock in thread?

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

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

Ques 30. What is thread pool in java?

Ques 31. What is concurrency in java?

Ques 32. What is reason of NoClassDefFoundError in Java?

Ques 33. How to resolve NoClassDefFoundError?

Ques 34. Difference between ClassNotFoundException and NoClassDefFoundError in Java?

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

Ques 36. Types of OutOfMemoryError in Java.

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

Ques 38. How HashMap works in Java?

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

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

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

Ques 42. What is abstraction?

Ques 43. String vs StringBuffer vs StringBuilder in Java

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

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

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

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

Ques 48. Difference between Vector and ArrayList in Java

Ques 49. What is Dictionary Class in Java?

Ques 50. What is Reference Handler Thread in Java?

Ques 51. What is Main thread in Java?

Ques 52. What is Signal Dispatcher thread in Java?

Ques 53. What is multithreading in Java?

Ques 54. What is keyword in Core Java?

Ques 55. What is identifier in java?

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

Ques 57. What is Unchecked Exception in java?

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

Ques 59. What is literals in core java?

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

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

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

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

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

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

Ques 66. What is the purpose of Void class?

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

Ques 68. What do you mean by a Classloader?

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

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

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

Ques 72. What is JIT and its use?

Ques 73. Is JVM a compiler or an interpreter?

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

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

Ques 76. What is the advantage of OOP?

Ques 77. What are the methods in Object?

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

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

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

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

Ques 82. Can you instantiate the Math class?

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

Ques 84. What is the volatile modifier for?

Ques 85. Is null a keyword?

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

Ques 87. Is 'abc' a primitive value?

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

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

Ques 90. Are true and false keywords?

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

Ques 92. Is sizeof a keyword?

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

Ques 94. Which Java operator is right associative?

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

Ques 96. Name the eight primitive Java types.

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

Ques 98. 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 99. Does Java have "goto"?

Ques 100. Explain the usage of the keyword transient?

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

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

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

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

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

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

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

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

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

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

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

Ques 112. What is the use of transient?

Ques 113. What is Externalizable?

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

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

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

Ques 117. Can a for statement loop indefinitely?

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

Ques 119. What is the % operator?

Ques 120. What are abstract classes, abstract methods?

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

Ques 122. What is the purpose of abstract class?

Ques 123. How to define an Abstract class?

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

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

Ques 126. What is an abstract method?

Ques 127. 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 128. What are interfaces?

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

Ques 130. How to define an Interface in Java ?

Ques 131. How many methods in the Serializable interface?

Ques 132. How many methods in the Externalizable interface?

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

Ques 134. Can an Interface have an inner class?

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

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

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

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

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

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

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

Ques 142. Can an Interface be final?

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

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

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

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

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

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

Ques 149. What is a transient variable?

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

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

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

Ques 153. What is the final keyword denotes?

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

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

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

Ques 157. What is a native method?

Ques 158. What is reflection?

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

Ques 160. Does Java have multiple inheritance?

Ques 161. What is the super class of Hashtable?

Ques 162. What are some alternatives to inheritance?

Ques 163. Is a class a subclass of itself?

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

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

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

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

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

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

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

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

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

Ques 173. What is composition?

Ques 174. What is aggregation?

Ques 175. Why isn't there operator overloading?

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

Ques 177. What restrictions are placed on method overloading?

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

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

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

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

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

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

Ques 184. What is a working thread?

Ques 185. What is a green thread?

Ques 186. What is a thread?

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

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

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

Ques 190. What are the states of a thread?

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

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

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

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

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

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

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

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

Ques 199. What is a daemon thread?

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

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

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

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

Ques 204. 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 205. How can you force garbage collection?

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

Ques 207. How does exception handling work in Java?

Ques 208. Does Java have destructors?

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

Ques 210. Can an exception be rethrown?

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

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

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

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

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

Ques 216. What is the purpose of garbage collection?

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

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

Ques 219. What is the finalize method do?

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

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

Ques 222. What is the purpose of finalization?

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

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

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

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

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

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

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

Ques 231. Which package is always imported by default?

Ques 232. What is a package?

Ques 233. Explain the usage of Java packages.

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

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

Ques 238. What is Collection API ?

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

Ques 240. What is the significance of ListIterator?

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

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

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

Ques 244. What is Locale?

Ques 245. How will you load a specific locale?

Ques 246. What is singleton?

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

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

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

Ques 250. What are wrapped classes?

Ques 251. What is casting?

Ques 252. What are E and PI?

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

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

Ques 255. How are Observer and Observable used?

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

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

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

Ques 259. What is Downcasting ?

Ques 260. How many static init can you have ?

Ques 261. What is mutable object and immutable object?

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

Ques 263. What is the byte range?

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

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

Ques 266. How is rounding performed under integer division?

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

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

Ques 269. What is a hashCode?

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

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

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

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

Ques 274. What is nested class?

Ques 275. What is inner class?

Ques 276. What is the use of serializable?

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

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

Ques 279. What an I/O filter?

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

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

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

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

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

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

Ques 286. What is a socket?

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

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

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

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

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

Ques 292. What is a lightweight component?

Ques 293. What is a heavyweight component?

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

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

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

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

Ques 298. What are java beans?

Ques 299. What is a DatabaseMetaData?

Ques 300. What is DriverManager?

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

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

Ques 303. What is the protocol used by RMI?

Ques 304. What is the use of PreparedStatement?

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

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

©2016 WithoutBook