A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Java Interview Questions

Java Interview Questions

300+ Java Interview Questions

We will go through different level of questions, which asked in an interview. Personally, me and my friends having experience in taking java interview in HCL, NIIT, Amdocs, Fidelity and IBM India. My friends also taking an interview based on this experience, we can suggest you go through this level and prepare before going to interview.

Java Interview Questions for 0-1 years of experience

  1. What is JDK, JRE and JVM?
  2. What public static void main(String args[]) in Java program?
  3. Why Java is platform-independent?
  4. Why Java is not 100% Object-oriented?
  5. What are wrapper classes in Java?
  6. What are constructors in Java?
  7. What is singleton class in Java and how can we make a class singleton?
  8. What is the difference between Array list and vector in Java?
  9. What is the difference between equals() and == in Java?
  10. What are the differences between Heap and Stack Memory in Java?

Java Interview Questions for 0-2 years of experience

  1. What is Polymorphism?
  2. What is runtime polymorphism or dynamic method dispatch?
  3. What is an abstraction in Java?
  4. What do you mean by an interface in Java?
  5. What is the difference between abstract classes and interfaces?
  6. What is inheritance in Java?
  7. What are the different types of inheritance in Java?
  8. What is method overloading and method overriding?
  9. Can you override a private or static method in Java?
  10. What are multiple inheritances? Is it supported by Java?
  11. What is encapsulation in Java?
  12. What is an association?
  13. What do you mean by aggregation?
  14. What is a composition in Java?
  15. What is a marker interface?
  16. What is object cloning in Java?
  17. What is a copy constructor in Java?
  18. What is a constructor overloading in Java?

Java Interview Questions for 0-3 years of experience

  1. What is a servlet?
  2. What are the differences between Get and Post methods?
  3. What is Request Dispatcher?
  4. What are the differences between forward() method and sendRedirect() methods?
  5. What is the life-cycle of a servlet?
  6. How does cookies work in Servlets?
  7. What are the differences between ServletContext vs ServletConfig?
  8. What are the different methods of session management in servlets?
  9. What is JDBC Driver?
  10. What are the steps to connect to a database in java?
  11. What are the JDBC API components?
  12. What is the role of JDBC DriverManager class?
  13. What is JDBC Connection interface?
  14. What is the purpose of JDBC ResultSet interface?
  15. What is JDBC ResultSetMetaData interface?
  16. What is JDBC DatabaseMetaData interface?
  17. What do you mean by batch processing in JDBC?
  18. What is the difference between execute, executeQuery, executeUpdate?
  19. What do you understand by JDBC Statements?

Java Interview Questions for 0-4 years of experience

  1. What is Spring?
  2. Name the different modules of the Spring framework.
  3. List some of the important annotations in annotation-based Spring configuration.
  4. Explain Bean in Spring and List the different Scopes of Spring bean.
  5. Explain the role of DispatcherServlet and ContextLoaderListener.
  6. What are the differences between constructor injection and setter injection?
  7. What is autowiring in Spring? What are the autowiring modes?
  8. How to handle exceptions in Spring MVC Framework?
  9. What are some of the important Spring annotations which you have used?
  10. How to integrate Spring and Hibernate Frameworks?
  11. Name the types of transaction management that Spring supports.
  12. What is Hibernate Framework?
  13. What are the important benefits of using Hibernate Framework?
  14. Explain Hibernate architecture.
  15. What are the differences between get and load methods?
  16. What are the advantages of Hibernate over JDBC?
  17. What are the life-cycle methods for a jsp?
  18. What are the JSP implicit objects?
  19. What are the differences between include directive and include action?
  20. How to disable caching on back button of the browser?
  21. What are the different tags provided in JSTL?
  22. How to disable session in JSP?
  23. How to delete a Cookie in a JSP?
  24. Explain the jspDestroy() method.
  25. How is JSP better than Servlet technology?
  26. Why should we not configure JSP standard tags in web.xml?
  27. How will you use JSP EL in order to get the HTTP method name?
  28. What is the difference between Error and Exception?
  29. How can you handle Java exceptions?
  30. What are the differences between Checked Exception and Unchecked Exception?
  31. Checked Exception
  32. What purpose do the keywords final, finally, and finalize fulfill?
  33. What are the differences between throw and throws?
  34. What is exception hierarchy in java?
  35. How to create a custom Exception?
  36. What are the important methods of Java Exception Class?
  37. What are the differences between processes and threads?
  38. What is a finally block? Is there a case when finally will not execute?
  39. What is synchronization?
  40. Can we write multiple catch blocks under single try block?
  41. What are the important methods of Java Exception Class?
  42. What is OutOfMemoryError in Java?
  43. What is a Thread?
  44. What are the two ways to create a thread?
  45. What are the different types of garbage collectors in Java?

Java Interview Questions for 0-5 years of experience

  1. What are the advantages of the Collection Framework in Java?
  2. What do you understand by Collection Framework in Java?
  3. Describe the Collection hierarchy in Java.
  4. List down the primary interfaces provided by Java Collections Framework?
  5. Why Collection doesn’t extend the Cloneable and Serializable interfaces?
  6. List down the major advantages of the Generic Collection.
  7. What is the main benefit of using the Properties file?
  8. What do you understand by Iterator in the Java Collection Framework?
  9. What is the need for overriding equals() method in Java?
  10. How the Collection objects are sorted in Java?
  11. What is the use of the List interface?
  12. What is ArrayList in Java?
  13. How would you convert an ArrayList to Array and an Array to ArrayList?
  14. What do you understand by LinkedList in Java? How many types of LinkedList does Java support?
  15. What are the various methods provided by the Queue interface?
  16. What is a Vector in Java?
  17. How will you reverse an List?
  18. What do you understand by BlockingQueue?
  19. What is a priority queue in Java?
  20. What is the Stack class in Java and what are the various methods provided by it?
  21. What is Set in Java Collections framework and list down its various implementations?
  22. What is the HashSet class in Java and how does it store elements?
  23. Can you add a null element into a TreeSet or HashSet?
  24. Explain the emptySet() method in the Collections framework?
  25. What is LinkedHashSet in Java Collections Framework?
  26. What is Map interface in Java?
  27. List down the different Collection views provided by the Map interface in the Java Collection framework?
  28. Why Map doesn’t extend the Collection Interface?
  29. What is the ConcurrentHashMap in Java and do you implement it?
  30. Can you use any class as a Map key?
  31. Differentiate between Collection and Collections.
  32. Differentiate between an Array and an ArrayList.
  33. Differentiate between Iterable and Iterator.
  34. Differentiate between ArrayList and LinkedList.
  35. Differentiate between an Array and an ArrayList.
  36. Differentiate between Iterable and Iterator.
  37. Differentiate between ArrayList and LinkedList.
  38. Differentiate between Comparable and Comparator.
  39. Differentiate between List and Set.
  40. Differentiate between Set and Map.
  41. Differentiate between List and Map.
  42. Differentiate between Queue and Stack.
  43. Differentiate between PriorityQueue and TreeSet.
  44. Differentiate between the Singly Linked List and Doubly Linked List.
  45. Differentiate between Iterator and Enumeration.
  46. Differentiate between HashMap and HashTable.
  47. Differentiate between HashSet and HashMap.
  48. Differentiate between Iterator and ListIterator.
  49. Differentiate between HashSet and TreeSet.
  50. Differentiate between Queue and Deque.
  51. Differentiate between HashMap and TreeMap.
  52. Differentiate between ArrayList and Vector.
  53. Differentiate between failfast and failsafe.

Java Interview Questions for 0-5 +years of experience

  1. Differentiate between Include Directive and Include Action.
  2. What is JSP?
  3. How can you include the results of another page?
  4. Mention some important JSP Action Tags.
  5. How can I use JSP in the MVC model?
  6. What do you mean by Context Initialization Parameters?
  7. Mention the scope values for <jsp.useBean> tag.
  8. What are the Literals used in JSP?
  9. What is the major difference between ServletContext and PageContext? 
  10. Why are the request.getRequestDispatcher() and context.getRequestDispatcher() used?
  11. List down the major differences between the JSP Custom Tags and Java Beans.
  12. How are Custom Tags in JSP created?
  13. Mention the various Implicit Objects used in the Expression
  14. Mention the three important tags used in the development of JSP Bean.
  15. Can you disable the caching on the back button of a particular browser?
  16. Mention the Implicit Objects in a JSP.
  17. Can you stop Multiple Submits to a Web Page that is initiated by clicking to refresh button?
  18. How to include static files in a JSP?
  19. How can we stop errors on Display in a JSP Page?
  20. Can a Constructor be used in place of init() method to initialize a servlet?
  21. What are the different Life-Cycle methods?
  22. What are the attributes on page directives?
  23. Explain Client-Side and Server-Side Validation.
  24. Explain Translation Phase.
  25. What is Object Cloning?
  26. Write a simple example for the Clone() Method.
  27. Define JSP Declaration.
  28. Differentiate between JSP Scriptlet tag and Declaration tag.
  29. How is JSP(Java Server Pages) better than ASP(Active Server Pages)?
  30. Mention the advantages of JSP over Pure Servlets?
  31. What is Auto-Flush Attribute?
  32. What do you mean by isScriptingEnabled Attribute?
  33. What are the steps involved in reading data from a form using JSP?
  34. How are cookies set in JSP?
  35. How do you delete the Session Data?
  36. How to delete a Cookie in JSP?
  37. Explain the difference between forward and sendRedirect?
  38. Mention the JSTL core tags.
  39. Why are JSP pages preferred for creating web-based client program?
  40. How can you make the Finally Clause not to fail to execute?
  41. How can we retrieve Warnings?
  42. Why Does Jcomponent have Add() And Remove() methods but the component does not?
  43. Explain some JSP Life-Cycle methods that can be overridden.
  44. How can I declare methods within my JSP page?
  45. How does a servlet communicate with a JSP page?
  46. What is Hidden Comment?
  47. Can you disable JSP Scripting?
  48. How to deactivate EL on JSP?
  49. When does a container initialize multiple JSP objects?
  50. Give a sample JSP configuration in the deployment descriptor.

Hibernate Interview Questions: 5 +years of experience

Q1. What is Hibernate?

Q2. What are the major advantages of Hibernate Framework?

Q3. What are the advantages of using Hibernate over JDBC?

Q4. What is an ORM tool?

Q5. Why use Hibernate Framework?

Q6. What are the different functionalities supported by Hibernate?

Q7. What are the technologies that are supported by Hibernate?

Q8. What is HQL?

Q9. How to achieve mapping in Hibernate?

Q10. Name some of the important interfaces of Hibernate framework?

Q11. What is One-to-One association in Hibernate?

Q12. What is One-to-Many association in Hibernate?

Q13. What is Many-to-Many association in Hibernate?

Q14. How to integrate Hibernate and Spring?

Q15. What do you mean by Hibernate Configuration File?

Q16. Mention some important annotations used for Hibernate mapping?

Q17. What is Session in Hibernate and how to get it?

Q18. What is Hibernate SessionFactory?

Q19. What is the difference between openSession and getCurrentSession?

Q20. What do you mean by Hibernate configuration file?

Q21. What are the key components of a Hibernate configuration object?

Q22. Discuss the Collections in Hibernate

Q23. What are the collection types in Hibernate?

Q24. What is a Hibernate Template class?

Q25. What are the benefits of using Hibernate template?

Q26. Which are the design patterns that are used in Hibernate framework?

Q27. Define Hibernate Validator Framework

Q28. What is Dirty Checking in Hibernate?

Q29. How can you share your views on mapping description files?

Q30. What is meant by Light Object Mapping?

Q31. What is meant by Hibernate tuning?

Q32. What is Transaction Management in Hibernate? How does it work?

Q33. How do you integrate Hibernate with Struts2 or Servlet web applications?

Q34. What are the different states of a persistent entity?

Q35. How can the primary key be created by using Hibernate?

Q36. Explain about Hibernate Proxy and how it helps in Lazy loading?

Q37. How can we see Hibernate generated SQL on console?

Q38. What is Query Cache in Hibernate?

Q39. What is the benefit of Native SQL query support in Hibernate?

Q40. What is Named SQL Query?

Q41. When do you use merge() and update() in Hibernate?

Q42. Difference between get() vs load() method in Hibernate?

Q43. Difference between the first and second level cache in Hibernate?

Q44. Difference between Session and SessionFactory in Hibernate?

Q45. Difference between save() and saveOrUpdate() method of Hibernate?

Q46. Difference between sorted and ordered collection in Hibernate?

Q47. Difference between the transient, persistent and detached state in Hibernate?

Q48. Difference between managed associations and Hibernate associations?

Q49. What are the best practices that Hibernate recommends for persistent classes?

Q50. What are the best practices to follow with Hibernate framework?