1. What is Java? Why is it platform-independent?
Java runs on JVM → bytecode → machine code → so it works on any OS.
2. Difference between JDK, JRE, and JVM
JDK → development kit
JRE → runtime environment
JVM → executes bytecode
3. OOPS Concepts (Infosys always asks)
Encapsulation
Inheritance
Polymorphism
Abstraction
4. Difference between Overloading and Overriding
Overloading – compile time, same method name, different params.
Overriding – runtime, same signature in subclass.
5. What is this keyword?
Refers to current object.
6. What is super keyword?
Refers to parent class.
7. What is constructor? Types?
Default
Parameterized
Used to initialize objects.
8. Difference between abstract class and interface
Abstract → can have concrete + abstract methods
Interface → only abstract methods (Java 8 allows default/static)
9. Can Java support multiple inheritance
10. What is String pool?
Area in heap memory that stores unique string literals.
11. Difference between String, StringBuilder, StringBuffer
String → immutable
StringBuilder → mutable, not thread-safe
StringBuffer → mutable, thread-safe
12. What is exception handling?
try, catch, finally, throw, throws
13. Checked vs Unchecked Exceptions
Checked → compile time (IOException)
Unchecked → runtime (ArithmeticException)
14. Collections vs Arrays
Collections grow dynamically, array has fixed length.
15. Difference between List, Set, Map
List → ordered, duplicates allowed
Set → unique, no duplicates
Map → key-value pairs
16. HashMap vs Hashtable
HashMap → not synchronized, faster
Hashtable → synchronized, slower
17. What is a Thread? How to create?
Extend Thread OR implement Runnable.
18. What is synchronization