Most Common Java Interview Questions
Core Java - Basics
- What are the features of Java?
- What is the difference between JDK, JRE, and JVM?
- Why is Java platform-independent?
- What is the difference between Java and C++?
- Why is Java not a pure object-oriented language?
- What are access modifiers in Java?
- What is the difference between == and `.equals()`?
- What is a constructor in Java? Types?
- What is the difference between static and non-static methods?
- What is the difference between final, finally, and finalize?
OOPs Concepts
- What are the four pillars of OOP?
- What is encapsulation in Java?
- What is inheritance in Java? Types?
- What is polymorphism in Java? Explain compile-time and runtime.
- What is abstraction? How is it achieved in Java?
- What is the difference between an abstract class and an interface?
- Can we instantiate an abstract class?
- What is method overloading and overriding?
- Can you override a static method in Java?
- What is the use of the `super` and `this` keyword?
Exception Handling
- What is exception handling in Java?
- What is the difference between checked and unchecked exceptions?
- What are try, catch, finally, throw, and throws?
- Can we have multiple catch blocks for a single try?
- Can we have a try block without a catch block?
Arrays & Strings
- What is the difference between Array and ArrayList?
- How to sort an array in Java?
- What is a String in Java?
- Why are strings immutable in Java?
- What is the difference between String, StringBuilder, and StringBuffer?
- What are common string methods (length, substring, indexOf, etc.)?
Collections Framework
- What is the Java Collections Framework?
- What is the difference between List, Set, and Map?
- What is the difference between ArrayList and LinkedList?
- What is the difference between HashSet and TreeSet?
- What is the difference between HashMap and Hashtable?
- What is the difference between HashMap and TreeMap?
- What are the differences between fail-fast and fail-safe?
- What is the use of Iterator and ListIterator?
- What is Comparable vs Comparator?
File Handling
- How do you create, read, and write a file in Java?
- What is the difference between FileReader and BufferedReader?
- What is the use of try-with-resources in Java?
- How to delete a file in Java?
- How to create directories programmatically?
Multithreading
- What is a thread in Java?
- How to create a thread in Java?
- What is the difference between extending Thread and implementing Runnable?
- What is the lifecycle of a thread?
- What is synchronization in Java?
- What is a deadlock?
- What are daemon threads?
Java 8 Features
- What are the new features in Java 8?
- What is a lambda expression?
- What are functional interfaces?
- What is the Stream API?
- What is the Optional class in Java?
JDBC
- What is JDBC?
- What are the steps to connect to a database using JDBC?
- What is the difference between Statement, PreparedStatement, and CallableStatement?
- How do you handle SQL exceptions?