1. What is Java?
Java is a high-level, object-oriented programming language. It is platform independent because Java programs run on JVM.
2. Why is Java platform independent?
Java code is compiled into bytecode, which can run on any operating system using JVM.
3. What is JVM?
JVM (Java Virtual Machine) executes Java bytecode and converts it into machine-specific instructions.
4. What is JDK?
JDK (Java Development Kit) is used to develop Java applications. It contains JRE and development tools.
5. What is JRE?
JRE (Java Runtime Environment) is used to run Java applications.
6. What are the features of Java?
Object Oriented, Platform Independent, Secure, Robust, Multithreaded, High Performance.
7. What is OOP?
OOP stands for Object Oriented Programming. It is based on objects and classes.
8. What are the four principles of OOP?
Encapsulation, Inheritance, Polymorphism, Abstraction.
9. What is Encapsulation?
Encapsulation is wrapping data and methods into a single unit and restricting access using access modifiers.
10. What is Inheritance?
Inheritance allows a class to acquire properties of another class using the extends keyword.
11. What is Polymorphism?
Polymorphism allows one method to perform different tasks. Example: method overloading and overriding.
12. What is Abstraction?
Abstraction hides implementation details and shows only required information.
13. What is the difference between abstract class and interface?
Abstract class can have method implementation. Interface supports multiple inheritance.
14. What is Constructor?
Constructor is a special method used to initialize objects.
15. Difference between == and equals()?
== compares references, while equals() compares content.
16. What is Exception?
Exception is an unwanted event that occurs at runtime and disrupts program flow.
17. What is Exception Handling?
Exception handling manages runtime errors using try, catch, finally, throw and throws.
18. Difference between checked and unchecked exception?
Checked exceptions are checked at compile time. Unchecked exceptions occur at runtime.
19. What is Multithreading?
Multithreading allows multiple threads to execute simultaneously for better performance.
20. What is Garbage Collection?
Garbage Collection removes unused objects from memory automatically.
21. Difference between Array and ArrayList?
Array has fixed size. ArrayList has dynamic size.
22. What is String in Java?
String is an immutable object that represents a sequence of characters.
23. Difference between String and StringBuffer?
String is immutable. StringBuffer is mutable and thread-safe.
24. What is final keyword?
Final keyword is used to restrict modification of variables, methods, and classes.
25. What is static keyword?
Static keyword belongs to the class rather than the object.