Q1: What is Java?
Java is a high-level, object-oriented, platform-independent programming language.
Q2: JDK vs JRE vs JVM
JDK = Development Kit, JRE = Runtime Environment, JVM = Executes Java bytecode.
Q3: Why is Java platform-independent?
Because Java code runs on JVM, not directly on OS.
Q4: Primitive data types
byte, short, int, long, float, double, char, boolean.
Q5: == vs equals()
== compares references, equals() compares values.
Q6: String vs StringBuilder vs StringBuffer
String immutable, StringBuilder mutable (not thread-safe), StringBuffer mutable (thread-safe).
Q7: What is OOP?
Programming paradigm based on objects.
Q8: OOP pillars
Encapsulation, Inheritance, Polymorphism, Abstraction.
Q9: Constructor
Special method used to initialize objects.
Q10: Method Overloading vs Overriding
Overloading = same method, different params.
Overriding = redefining parent method.
Q11: final keyword
Used to restrict modification (variable, method, class).
Q12: this vs super
this refers to current object, super refers to parent class.
Q13: Static keyword
Belongs to class, not instance.
Q14: Access modifiers
public, private, protected, default.
Q15: Interface vs Abstract class
Interface = only abstract methods (mostly).
Abstract class = can have both.
Q16: Exception Handling
try, catch, finally, throw, throws.
Q17: Checked vs Unchecked exceptions
Checked = compile-time, Unchecked = runtime.
Q18: Collections Framework
Set of classes/interfaces like List, Set, Map.
Q19: List vs Set
List allows duplicates, Set does not.
Q20: HashMap vs HashTable
HashMap not synchronized, HashTable synchronized.
Q21: Array vs ArrayList
Array fixed size, ArrayList dynamic.
Q22: Iterator
Used to traverse collections.
Q23: Comparable vs Comparator
Comparable = natural ordering, Comparator = custom ordering.
Q24: Multithreading
Executing multiple threads simultaneously.
Q25: Thread lifecycle
New → Runnable → Running → Blocked → Terminated.
Q26: synchronized keyword
Controls thread access to shared resources.
Q27: volatile keyword
Ensures visibility of variables across threads.
Q28: Garbage Collection
Automatic memory management in Java.
Q29: finalize() method
Called before object is garbage collected (deprecated in modern Java).
Q30: JVM memory areas
Heap, Stack, Method Area, PC Register.
Q31: String pool
Special memory area for string literals.
Q32: Serialization
Converting object into byte stream.
Q33: transient keyword
Prevents variable from serialization.
Q34: File handling
Using File, FileReader, BufferedReader, etc.
Q35: Java 8 features
Lambda, Stream API, Functional interfaces.
Q36: Lambda expression
Short way to write functions.
Q37: Stream API
Used for functional-style operations on collections.
Q38: Optional class
Avoids NullPointerException.
Q39: Map interface
Stores key-value pairs.
Q40: REST API in Java
Built using frameworks like Spring Boot.
Q41: Spring Framework
Used for enterprise applications.
Q42: Hibernate
ORM tool for database operations.
Q43: JDBC
Java API to connect with databases.
Q44: Microservices
Architecture style for building scalable apps.
Q45: Design patterns
Reusable solutions (Singleton, Factory, etc.).
Q46: Singleton pattern
Ensures single instance of class.
Q47: Dependency Injection
Provides objects instead of creating them.
Q48: JVM vs JIT
JVM executes bytecode, JIT compiles to native code.
Q49: Java vs Python
Java is statically typed, Python is dynamically typed.
Q50: Why Java for interviews?
Widely used, strong OOP concepts, enterprise demand.