Top 50 Core Java Interview Questions with Answers


1)  How Java achieves platform independence? (answer)



2)  What is ClassLoader in Java? (answer)



3)  Write a Java program to check if a number is Even or Odd? (answer)



4)  Difference between ArrayList and HashSet in Java? (answer)



5)  What is double checked locking in Singleton? (answer)



6)  How do you create thread-safe Singleton in Java? (answer)



7)  When to use volatile variable in Java? (answer)



8)  When to use a transient variable in Java? (answer)



9)  Difference between transient and volatile variable in Java? (answer)



10) Difference between Serializable and Externalizable in Java? (answer)



11) Can we override a private method in Java? (answer)



12) Difference between Hashtable and HashMap in Java? (answer)



13) Difference between List and Set in Java? (answer)



14) Difference between ArrayList and Vector in Java



15) Difference between Hashtable and ConcurrentHashMap in Java? (answer)



16) How does ConcurrentHashMap achieve scalability? (answer)



17) Which two methods you will override for an Object to be used as Key in HashMap? (answer)



18) Difference between wait and sleep in Java? (answer)



19) Difference between notify and notifyAll in Java? (answer)



20) Why you override hashcode, along with equals() in Java? (answer)



21) What is load factor of HashMap means? (answer)



22) Difference between ArrayList and LinkedList in Java? (answer)



23) Difference between CountDownLatch and CyclicBarrier in Java? (answer)



24) When do you use Runnable vs Thread in Java? (answer)



25) What is the meaning of Enum being type-safe in Java? (answer)



26) How does Autoboxing of Integer work in Java? (answer)



27) Difference between PATH and Classpath in Java? (answer)



28) Difference between method overloading and overriding in Java? (answer)



29) How do you prevent a class from being sub-classed in Java? (answer)



30) How do you restrict your class from being used by your client? (answer)



31) Difference between StringBuilder and StringBuffer in Java? (answer)



32) Difference between Polymorphism and Inheritance in Java? (answer)



33) Can we override static method in Java? (answer)



34) Can we access private method in Java? (answer)



35) Difference between interface and abstract class in Java? (answer)



36) Difference between DOM and SAX parser in Java? (answer)



37) Difference between throw and throws keyword in Java? (answer)



38) Difference between fail-safe and fail-fast iterators in Java? (answer)



39) Difference between Iterator and Enumeration in Java? (answer)



40) What is identity HashMap in Java? (answer)



41) What is String pool in Java? (answer)



42) Can a Serializable class contain a non serializable field in Java? (answer)



43) Difference between this and super in Java? (answer)



44) Difference between Comparator and Comparable in Java? (answer)



45) Difference between java.util.Date and java.sql.Date in Java? (answer)



46) Why wait and notify method are declared in Object class in Java? (answer)



47) Why Java doesn't support multiple inheritances? (answer)



48) Difference between checked and unchecked Exception in Java? (answer)



49) Difference between Error and Exception in Java? (answer)



50) Difference between race condition and deadlock in Java? (answer)

No comments:

Post a Comment

Feel free to comment, ask questions if you have any doubt.