Core Java Concepts (1-10)
1. Main features of Java: Platform independence (write once, run anywhere), object-
oriented, automatic memory management, strongly typed, multithreading support,
robust exception handling, and extensive standard library.
2. JDK vs JRE vs JVM:
• JVM: Executes bytecode, provides runtime environment
• JRE: JVM + libraries needed to run Java applications
• JDK: JRE + development tools (compiler, debugger, etc.)
3. Java Virtual Machine (JVM): Runtime engine that executes Java bytecode, providing
platform independence through abstraction layer between code and operating system.
4. Object-Oriented Programming in Java: Based on classes and objects with four pillars:
encapsulation (data hiding), inheritance (extending classes), polymorphism (multiple
forms), and abstraction (hiding implementation details).
5. == vs .equals(): == compares reference/memory address for objects (value for
primitives), while .equals() compares content/logical equality of objects.
6. Access modifiers:
• private: Same class only
• default: Same package
• protected: Same package + subclasses
• public: Accessible everywhere
7. Abstract class vs Interface: Abstract classes can have concrete methods,
constructors, instance variables, and support single inheritance. Interfaces (pre-Java 8)
have only abstract methods, no constructors, only constants, and support multiple
inheritance.
8. Constructor: Special method for object initialization. Types: default (no-arg),
parameterized, and copy constructor.
9. Overloading vs Overriding:
• Overloading: Same method name, different parameters (compile-time)
• Overriding: Redefining parent method in child class (runtime)
10. Static vs non-static methods: Static methods belong to class, called without object,
can't access instance variables. Non-static methods require object instance, can
access both static and instance members.
Keywords & Strings (11-17)
11. final keyword: Makes variables constant, methods non-overridable, and classes
non-inheritable.
12. Package: Namespace for organizing related classes and interfaces, preventing
naming conflicts.
13. this vs super:
• this: References current object
• super: References parent class object/constructor
14. String vs StringBuilder vs StringBuffer:
• String: Immutable, thread-safe
• StringBuilder: Mutable, not thread-safe, fastest
• StringBuffer: Mutable, thread-safe, slower than StringBuilder
15. Exceptions:
• Checked: Compile-time, must be handled (IOException)
• Unchecked: Runtime exceptions (NullPointerException)
16. try-catch-finally: try block contains risky code, catch handles exceptions, finally
always executes (cleanup).
17. throw vs throws:
• throw: Explicitly throws exception instance
• throws: Declares method might throw exceptions
Multithreading (18-20)
18. Multithreading: Concurrent execution of multiple threads within a program for better
resource utilization.
19. Synchronization: Controlling thread access to shared resources using synchronized
keyword to prevent race conditions.
20. Thread lifecycle: NEW → RUNNABLE → BLOCKED/WAITING/TIMED_WAITING →
TERMINATED
Collections (21-26)
21. Collections: Framework providing interfaces (List, Set, Map) and implementations
for storing and manipulating groups of objects.
22. List vs Set vs Map:
• List: Ordered, allows duplicates
• Set: No duplicates, may be unordered
• Map: Key-value pairs, unique keys
23. ArrayList vs LinkedList:
• ArrayList: Dynamic array, fast random access, slow insertion/deletion
• LinkedList: Doubly-linked list, fast insertion/deletion, slow random access
24. HashMap: Hash table implementation of Map interface, stores key-value pairs,
allows one null key.
25. HashMap vs Hashtable: HashMap is non-synchronized, allows null, faster.
Hashtable is synchronized, no nulls, legacy.
26. hashCode() and equals() contract: If two objects are equal (equals() returns true),
they must have same hashCode(). Same hashCode doesn't guarantee equality.
Java 8+ Features (27-33)
27. Generics: Type parameters providing compile-time type safety and eliminating
casting: List<String>
28. Enum: Special class representing fixed set of constants with type safety.
29. Lambda expression: Concise way to write anonymous functions: (x, y) -> x + y
30. Functional interface: Interface with single abstract method, can be used with
lambdas (@FunctionalInterface).
31. Stream API: Functional-style operations on collections: filter, map, reduce, collect.
32. Optional: Container object to avoid null pointer exceptions, represents presence or
absence of value.
33. Default and static methods in interfaces: Default methods provide implementation,
static methods are utility methods called on interface itself.
Memory & Advanced (34-50)
34. Garbage collection: Automatic memory management that reclaims unused objects
from heap.
35. finalize() method: Called before garbage collection (deprecated in Java 9).
36. Annotations: Metadata providing information about code (@Override,
@Deprecated, custom annotations).
37. Reflection: Examining and modifying runtime behavior of classes, methods, fields
programmatically.
38. Serialization/Deserialization: Converting object to byte stream (serialization) and
vice versa (deserialization) for storage/transmission.
39. transient keyword: Prevents field from being serialized.
40. Memory management: Automatic via garbage collection, heap stores objects, stack
stores method calls and primitives.
41. JDBC: Java Database Connectivity - API for database operations.
42. Database connection:
java
Connection conn = [Link](url, username, password);
43. Statement vs PreparedStatement: PreparedStatement is precompiled, prevents SQL
injection, better for repeated queries with parameters.
44. Singleton pattern: Ensures only one instance of class exists using private
constructor and static getInstance() method.
45. Factory pattern: Creates objects without specifying exact class, using common
interface.
46. Dependency injection: Providing dependencies externally rather than creating them
internally, improving testability and flexibility.
47. Stack vs Heap memory:
• Stack: Stores primitives, references, method calls (LIFO)
• Heap: Stores objects, shared across threads
48. Inner classes: Classes defined within other classes: static nested, non-static inner,
local, anonymous.
49. Exception handling best practices: Use specific exceptions, don't catch
Exception/Throwable, clean resources in finally/try-with-resources, log appropriately,
fail fast.
50. Debugging Java applications: Use IDE debuggers (breakpoints, step through),
logging frameworks (Log4j, SLF4J), profilers for performance, stack traces for
exceptions, JVM monitoring tools (JConsole, VisualVM).