➢ Java Interview Questions
By Abhishek Rathor
Instagram: code.abhii07 (SYNTAX ERROR)
1. What is Java?
Java is a high-level, object-oriented programming language developed by Sun Microsystems.
It is platform-independent due to the use of JVM.
2. Why is Java platform-independent?
Java code is compiled into bytecode, which runs on the Java Virtual Machine (JVM). JVM
makes Java programs run on any operating system.
3. What is JVM?
JVM (Java Virtual Machine) is responsible for executing Java bytecode. It provides runtime
environment and memory management.
4. What is JDK?
JDK (Java Development Kit) is a software package used to develop Java applications. It
includes JRE and development tools like compiler.
5. What is JRE?
JRE (Java Runtime Environment) provides libraries and JVM to run Java programs. It does
not include development tools.
6. Difference between Java and C++?
Java does not support pointers and multiple inheritance through classes, making it more
secure. Java is platform-independent, while C++ is not.
7. What is Object-Oriented Programming?
OOP is a programming concept based on objects and classes. It improves code reusability,
security, and maintainability.
8. What are the four pillars of OOP?
The four pillars are Encapsulation, Inheritance, Polymorphism, and Abstraction.
9. What is a class?
A class is a blueprint used to create objects. It defines variables and methods common to all
objects.
10. What is an object?
An object is an instance of a class. It represents real-world entities and contains actual data.
11. What is encapsulation?
Encapsulation is the process of wrapping data and methods into a single unit. It helps protect
data using access modifiers.
12. What is inheritance?
Inheritance allows one class to acquire properties of another class. It supports code reusability
and hierarchical structure.
13. What is polymorphism?
Polymorphism allows one method to perform different tasks based on object type. It is
achieved using method overloading and overriding.
14. What is abstraction?
Abstraction hides implementation details and shows only essential features. It is achieved
using abstract classes and interfaces.
15. Difference between abstract class and interface?
An abstract class can have method implementations, while an interface only has abstract
methods (before Java 8). A class can extend one abstract class but implement multiple
interfaces.
16. What is method overloading?
Method overloading allows multiple methods with the same name but different parameters. It
happens at compile time.
17. What is method overriding?
Method overriding allows a child class to provide its own implementation of a parent class
method. It happens at runtime.
18. What is constructor?
A constructor is a special method used to initialize objects. It is called automatically when an
object is created.
19. Difference between constructor and method?
A constructor initializes objects and has the same name as the class. A method performs
operations and has a return type.
20. What is this keyword?
The this keyword refers to the current object of a class. It is used to differentiate instance
variables from local variables.
21. What is static keyword?
The static keyword is used for memory management. Static members belong to the class,
not to objects.
22. What is final keyword?
The final keyword is used to restrict modification. A final variable cannot change, a final
method cannot be overridden, and a final class cannot be inherited.
23. What is exception handling?
Exception handling is used to handle runtime errors gracefully. It uses try, catch, finally,
throw, and throws keywords.
24. Difference between checked and unchecked exceptions?
Checked exceptions are checked at compile time, while unchecked exceptions occur at
runtime.
25. What is garbage collection?
Garbage collection automatically removes unused objects from memory. It helps prevent
memory leaks.
26. What is multithreading?
Multithreading allows multiple threads to run concurrently. It improves performance and
efficient CPU utilization.
27. What is synchronization?
Synchronization controls access to shared resources in multithreading. It prevents data
inconsistency.
28. What is String in Java?
String is an immutable class used to store character sequences. Once created, its value cannot
be changed.
29. Difference between String, StringBuilder, and StringBuffer?
String is immutable, StringBuilder is mutable and fast, StringBuffer is mutable and thread-
safe.
30. What is Collections Framework?
The Collections Framework provides predefined classes and interfaces to store and
manipulate groups of objects efficiently.
Connect & Share:
Tag us on your success
stories:
• Instagram: @code.abhii07
• YouTube: SYNTAX ERROR