![](https://programmingdoor.com/wp-content/uploads/2023/02/programmingdoor.com_java_interview_questions_20-20Commonly-20Asked-20Java-20Interview-20Questions-20and-20Answers-300x212.png)
![](https://programmingdoor.com/wp-content/uploads/2023/02/programmingdoor.com_java_interview_questions_20-20Commonly-20Asked-20Java-20Interview-20Questions-20and-20Answers-300x212.png)
- What is Java?
- Java is a high-level, object-oriented programming language designed to run on a variety of platforms.
- What are the features of Java?
- The main features of Java are platform independence, object-oriented programming, garbage collection, security, and multi-threading.
- What is the difference between an object and a class?
- A class is a blueprint or template for creating objects, while an object is an instance of a class.
- What is an interface in Java?
- An interface is a collection of abstract methods that can be implemented by any class.
- What is the difference between abstract classes and interfaces?
- An abstract class can have both abstract and non-abstract methods, while an interface can only have abstract methods.
- What is the purpose of the final keyword in Java?
- The final keyword can be used to make a variable, method or class immutable, which means they cannot be changed.
- What is the difference between static and non-static methods in Java?
- A static method can be accessed without creating an instance of a class, while a non-static method can only be accessed through an instance of a class.
- What is the purpose of the ‘this’ keyword in Java?
- The ‘this’ keyword refers to the current object and can be used to access its fields and methods.
- What is a constructor in Java?
- A constructor is a special method that is called when an object is created to initialize its state.
- What is inheritance in Java?
- Inheritance is a mechanism in which a new class is derived from an existing class, inheriting its properties and methods.
- What is polymorphism in Java?
- Polymorphism is the ability of an object to take on many forms, depending on the context in which it is used.
- What is the difference between a stack and a queue?
- A stack is a Last-In-First-Out (LIFO) data structure, while a queue is a First-In-First-Out (FIFO) data structure.
- What is a thread in Java?
- A thread is a lightweight process that can be used to achieve multi-tasking in a Java program.
- What is synchronization in Java?
- Synchronization is the process of coordinating access to shared resources to prevent race conditions and ensure consistency in a multi-threaded environment.
- What is exception handling in Java?
- Exception handling is a mechanism to handle errors and exceptions that may occur during the execution of a program.
- What is the difference between checked and unchecked exceptions in Java?
- Checked exceptions are checked at compile time, while unchecked exceptions are not.
- What is the purpose of the ‘throw’ keyword in Java?
- The ‘throw’ keyword is used to explicitly throw an exception in a program.
- What is the purpose of the ‘finally’ block in Java?
- The ‘finally’ block is used to execute a block of code, regardless of whether an exception is thrown or not.
- What is the difference between a HashMap and a HashTable in Java?
- HashMap is not synchronized and allows null values, while HashTable is synchronized and does not allow null values.
- What is the purpose of the ‘super’ keyword in Java?
- The ‘super’ keyword is used to refer to the superclass of a class and can be used to call its constructors and methods.