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
- What is JDK, JRE and JVM?
- What public static void main(String args[]) in Java program?
- Why Java is platform-independent?
- Why Java is not 100% Object-oriented?
- What are wrapper classes in Java?
- What are constructors in Java?
- What is singleton class in Java and how can we make a class singleton?
- What is the difference between Array list and vector in Java?
- What is the difference between equals() and == in Java?
- What are the differences between Heap and Stack Memory in Java?
Java Interview Questions for 0-2 years of experience
- What is Polymorphism?
- What is runtime polymorphism or dynamic method dispatch?
- What is an abstraction in Java?
- What do you mean by an interface in Java?
- What is the difference between abstract classes and interfaces?
- What is inheritance in Java?
- What are the different types of inheritance in Java?
- What is method overloading and method overriding?
- Can you override a private or static method in Java?
- What are multiple inheritances? Is it supported by Java?
- What is encapsulation in Java?
- What is an association?
- What do you mean by aggregation?
- What is a composition in Java?
- What is a marker interface?
- What is object cloning in Java?
- What is a copy constructor in Java?
- What is a constructor overloading in Java?
Java Interview Questions for 0-3 years of experience
- What is a servlet?
- What are the differences between Get and Post methods?
- What is Request Dispatcher?
- What are the differences between forward() method and sendRedirect() methods?
- What is the life-cycle of a servlet?
- How does cookies work in Servlets?
- What are the differences between ServletContext vs ServletConfig?
- What are the different methods of session management in servlets?
- What is JDBC Driver?
- What are the steps to connect to a database in java?
- What are the JDBC API components?
- What is the role of JDBC DriverManager class?
- What is JDBC Connection interface?
- What is the purpose of JDBC ResultSet interface?
- What is JDBC ResultSetMetaData interface?
- What is JDBC DatabaseMetaData interface?
- What do you mean by batch processing in JDBC?
- What is the difference between execute, executeQuery, executeUpdate?
- What do you understand by JDBC Statements?
Java Interview Questions for 0-4 years of experience
- What is Spring?
- Name the different modules of the Spring framework.
- List some of the important annotations in annotation-based Spring configuration.
- Explain Bean in Spring and List the different Scopes of Spring bean.
- Explain the role of DispatcherServlet and ContextLoaderListener.
- What are the differences between constructor injection and setter injection?
- What is autowiring in Spring? What are the autowiring modes?
- How to handle exceptions in Spring MVC Framework?
- What are some of the important Spring annotations which you have used?
- How to integrate Spring and Hibernate Frameworks?
- Name the types of transaction management that Spring supports.
- What is Hibernate Framework?
- What are the important benefits of using Hibernate Framework?
- Explain Hibernate architecture.
- What are the differences between get and load methods?
- What are the advantages of Hibernate over JDBC?
- What are the life-cycle methods for a jsp?
- What are the JSP implicit objects?
- What are the differences between include directive and include action?
- How to disable caching on back button of the browser?
- What are the different tags provided in JSTL?
- How to disable session in JSP?
- How to delete a Cookie in a JSP?
- Explain the jspDestroy() method.
- How is JSP better than Servlet technology?
- Why should we not configure JSP standard tags in web.xml?
- How will you use JSP EL in order to get the HTTP method name?
- What is the difference between Error and Exception?
- How can you handle Java exceptions?
- What are the differences between Checked Exception and Unchecked Exception?
- Checked Exception
- What purpose do the keywords final, finally, and finalize fulfill?
- What are the differences between throw and throws?
- What is exception hierarchy in java?
- How to create a custom Exception?
- What are the important methods of Java Exception Class?
- What are the differences between processes and threads?
- What is a finally block? Is there a case when finally will not execute?
- What is synchronization?
- Can we write multiple catch blocks under single try block?
- What are the important methods of Java Exception Class?
- What is OutOfMemoryError in Java?
- What is a Thread?
- What are the two ways to create a thread?
- What are the different types of garbage collectors in Java?
Java Interview Questions for 0-5 years of experience
- What are the advantages of the Collection Framework in Java?
- What do you understand by Collection Framework in Java?
- Describe the Collection hierarchy in Java.
- List down the primary interfaces provided by Java Collections Framework?
- Why Collection doesn’t extend the Cloneable and Serializable interfaces?
- List down the major advantages of the Generic Collection.
- What is the main benefit of using the Properties file?
- What do you understand by Iterator in the Java Collection Framework?
- What is the need for overriding equals() method in Java?
- How the Collection objects are sorted in Java?
- What is the use of the List interface?
- What is ArrayList in Java?
- How would you convert an ArrayList to Array and an Array to ArrayList?
- What do you understand by LinkedList in Java? How many types of LinkedList does Java support?
- What are the various methods provided by the Queue interface?
- What is a Vector in Java?
- How will you reverse an List?
- What do you understand by BlockingQueue?
- What is a priority queue in Java?
- What is the Stack class in Java and what are the various methods provided by it?
- What is Set in Java Collections framework and list down its various implementations?
- What is the HashSet class in Java and how does it store elements?
- Can you add a null element into a TreeSet or HashSet?
- Explain the emptySet() method in the Collections framework?
- What is LinkedHashSet in Java Collections Framework?
- What is Map interface in Java?
- List down the different Collection views provided by the Map interface in the Java Collection framework?
- Why Map doesn’t extend the Collection Interface?
- What is the ConcurrentHashMap in Java and do you implement it?
- Can you use any class as a Map key?
- Differentiate between Collection and Collections.
- Differentiate between an Array and an ArrayList.
- Differentiate between Iterable and Iterator.
- Differentiate between ArrayList and LinkedList.
- Differentiate between an Array and an ArrayList.
- Differentiate between Iterable and Iterator.
- Differentiate between ArrayList and LinkedList.
- Differentiate between Comparable and Comparator.
- Differentiate between List and Set.
- Differentiate between Set and Map.
- Differentiate between List and Map.
- Differentiate between Queue and Stack.
- Differentiate between PriorityQueue and TreeSet.
- Differentiate between the Singly Linked List and Doubly Linked List.
- Differentiate between Iterator and Enumeration.
- Differentiate between HashMap and HashTable.
- Differentiate between HashSet and HashMap.
- Differentiate between Iterator and ListIterator.
- Differentiate between HashSet and TreeSet.
- Differentiate between Queue and Deque.
- Differentiate between HashMap and TreeMap.
- Differentiate between ArrayList and Vector.
- Differentiate between failfast and failsafe.
Java Interview Questions for 0-5 +years of experience
- Differentiate between Include Directive and Include Action.
- What is JSP?
- How can you include the results of another page?
- Mention some important JSP Action Tags.
- How can I use JSP in the MVC model?
- What do you mean by Context Initialization Parameters?
- Mention the scope values for <jsp.useBean> tag.
- What are the Literals used in JSP?
- What is the major difference between ServletContext and PageContext?
- Why are the request.getRequestDispatcher() and context.getRequestDispatcher() used?
- List down the major differences between the JSP Custom Tags and Java Beans.
- How are Custom Tags in JSP created?
- Mention the various Implicit Objects used in the Expression
- Mention the three important tags used in the development of JSP Bean.
- Can you disable the caching on the back button of a particular browser?
- Mention the Implicit Objects in a JSP.
- Can you stop Multiple Submits to a Web Page that is initiated by clicking to refresh button?
- How to include static files in a JSP?
- How can we stop errors on Display in a JSP Page?
- Can a Constructor be used in place of init() method to initialize a servlet?
- What are the different Life-Cycle methods?
- What are the attributes on page directives?
- Explain Client-Side and Server-Side Validation.
- Explain Translation Phase.
- What is Object Cloning?
- Write a simple example for the Clone() Method.
- Define JSP Declaration.
- Differentiate between JSP Scriptlet tag and Declaration tag.
- How is JSP(Java Server Pages) better than ASP(Active Server Pages)?
- Mention the advantages of JSP over Pure Servlets?
- What is Auto-Flush Attribute?
- What do you mean by isScriptingEnabled Attribute?
- What are the steps involved in reading data from a form using JSP?
- How are cookies set in JSP?
- How do you delete the Session Data?
- How to delete a Cookie in JSP?
- Explain the difference between forward and sendRedirect?
- Mention the JSTL core tags.
- Why are JSP pages preferred for creating web-based client program?
- How can you make the Finally Clause not to fail to execute?
- How can we retrieve Warnings?
- Why Does Jcomponent have Add() And Remove() methods but the component does not?
- Explain some JSP Life-Cycle methods that can be overridden.
- How can I declare methods within my JSP page?
- How does a servlet communicate with a JSP page?
- What is Hidden Comment?
- Can you disable JSP Scripting?
- How to deactivate EL on JSP?
- When does a container initialize multiple JSP objects?
- 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?